Skip to content

Commit

Permalink
feat: pages admin + path parsing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Jul 2, 2019
1 parent 4f968cf commit 13f1729
Show file tree
Hide file tree
Showing 13 changed files with 454 additions and 45 deletions.
4 changes: 4 additions & 0 deletions client/components/admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
v-list-tile(to='/auth')
v-list-tile-avatar: v-icon lock_outline
v-list-tile-title {{ $t('admin:auth.title') }}
v-list-tile(to='/comments', disabled)
v-list-tile-avatar: v-icon(color='grey lighten-2') comment
v-list-tile-title {{ $t('admin:comments.title') }}
v-list-tile(to='/editor', disabled)
v-list-tile-avatar: v-icon(color='grey lighten-2') transform
v-list-tile-title {{ $t('admin:editor.title') }}
Expand Down Expand Up @@ -141,6 +144,7 @@ const router = new VueRouter({
{ path: '/locale', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-locale.vue') },
{ path: '/navigation', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-navigation.vue') },
{ path: '/pages', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages.vue') },
{ path: '/pages/:id', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages-edit.vue') },
{ path: '/theme', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-theme.vue') },
{ path: '/groups', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups.vue') },
{ path: '/groups/:id', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups-edit.vue') },
Expand Down
8 changes: 6 additions & 2 deletions client/components/admin/admin-navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
v-else-if='current.targetType === "page"'
color='indigo'
dark
@click='selectPage'
)
v-icon(left) search
span Select Page...
Expand Down Expand Up @@ -162,8 +163,8 @@ export default {
return [
{ text: this.$t('navigation.navType.external'), value: 'external' },
{ text: this.$t('navigation.navType.home'), value: 'home' },
{ text: this.$t('navigation.navType.page'), value: 'page' },
{ text: this.$t('navigation.navType.searchQuery'), value: 'search' }
{ text: this.$t('navigation.navType.page'), value: 'page' }
// { text: this.$t('navigation.navType.searchQuery'), value: 'search' }
]
}
},
Expand Down Expand Up @@ -197,6 +198,9 @@ export default {
selectItem(item) {
this.current = item
},
selectPage() {
window.alert(`Coming soon. Use External Link for now (you can still specify internal links).`)
},
async save() {
this.$store.commit(`loadingStart`, 'admin-navigation-save')
try {
Expand Down
236 changes: 236 additions & 0 deletions client/components/admin/admin-pages-edit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<template lang='pug'>
v-container(fluid, grid-list-lg)
v-layout(row, wrap, v-if='page.id')
v-flex(xs12)
.admin-header
img.animated.fadeInUp(src='/svg/icon-view-details.svg', alt='Edit Page', style='width: 80px;')
.admin-header-title
.headline.blue--text.text--darken-2.animated.fadeInLeft Page Details
.subheading.grey--text.animated.fadeInLeft.wait-p2s
v-chip.ml-0.mr-2(label, small).caption ID {{page.id}}
span /{{page.locale}}/{{page.path}}
v-spacer
template(v-if='page.isPublished')
status-indicator.mr-3(positive, pulse)
.caption.green--text {{$t('common:page.published')}}
template(v-else)
status-indicator.mr-3(negative, pulse)
.caption.red--text {{$t('common:page.unpublished')}}
template(v-if='page.isPrivate')
status-indicator.mr-3.ml-4(intermediary, pulse)
.caption.deep-orange--text {{$t('common:page.private')}}
template(v-else)
status-indicator.mr-3.ml-4(active, pulse)
.caption.blue--text {{$t('common:page.global')}}
v-spacer
v-btn.animated.fadeInRight.wait-p4s(color='grey', large, outline, to='/pages')
v-icon arrow_back
v-divider.animated.fadeInRight.wait-p3s.mx-3(vertical)
v-dialog(v-model='deletePageDialog', max-width='500')
v-btn.animated.fadeInDown.wait-p1s(color='red', large, outline, slot='activator')
v-icon(color='red') delete
v-card.wiki-form
.dialog-header.is-short.is-red
v-icon.mr-2(color='white') highlight_off
span {{$t('common:page.delete')}}
v-card-text
i18next.body-2(path='common:page.deleteTitle', tag='div')
span.red--text.text--darken-2(place='title') {{page.title}}
.caption {{$t('common:page.deleteSubtitle')}}
v-chip.mt-3.ml-0.mr-1(label, color='red lighten-4', disabled, small)
.caption.red--text.text--darken-2 {{page.locale.toUpperCase()}}
v-chip.mt-3.mx-0(label, color='red lighten-5', disabled, small)
span.red--text.text--darken-2 /{{page.path}}
v-card-chin
v-spacer
v-btn(flat, @click='deletePageDialog = false', :disabled='loading') {{$t('common:actions.cancel')}}
v-btn(color='red darken-2', @click='deletePage', :loading='loading').white--text {{$t('common:actions.delete')}}
v-btn.animated.fadeInDown(color='teal', large, outline, @click='rerenderPage')
v-icon(left) system_update_alt
span Re-render
v-flex(xs12, lg6)
v-card.animated.fadeInUp
v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 subject
span Properties
v-list.py-0(two-line, dense)
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Title
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.title }}
v-divider
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Description
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.description || '-' }}
v-divider
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Locale
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.locale }}
v-list-tile-action
v-btn(icon)
v-icon(color='grey') edit
v-divider
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Path
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.path }}
v-list-tile-action
v-btn(icon)
v-icon(color='grey') edit
v-divider
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Editor
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.editor || '?' }}
v-divider
v-list-tile
v-list-tile-content
v-list-tile-title.caption.grey--text Content Type
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.contentType || '?' }}

v-toolbar.elevation-2.mt-3.animated.fadeInUp.wait-p4s(color='white', dense)
v-spacer
v-btn(color='primary', flat, :href='`/` + page.locale + `/` + page.path')
v-icon(left) subject
span View
v-divider(vertical)
v-btn(color='primary', flat, :href='`/e/` + page.locale + `/` + page.path')
v-icon(left) edit
span Edit
v-divider(vertical)
v-btn(color='primary', flat, :href='`/s/` + page.locale + `/` + page.path')
v-icon(left) code
span Source
v-divider(vertical)
v-btn(color='primary', flat, :href='`/h/` + page.locale + `/` + page.path')
v-icon(left) history
span History
v-spacer

.caption.mt-4.grey--text.animated.fadeInUp.wait-p6s Page Hash: {{ page.hash }}

v-flex(xs12, lg6)
v-card.animated.fadeInUp.wait-p2s
v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 people
span Users
v-list.py-0(two-line, dense)
v-list-tile
v-list-tile-avatar
v-btn(icon, :to='`/users/` + page.creatorId')
v-icon(color='grey') person
v-list-tile-content
v-list-tile-title.caption.grey--text Creator
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.creatorName }} #[em.caption ({{ page.creatorEmail }})]
v-list-tile-action
v-list-tile-action-text {{ page.createdAt | moment('calendar') }}
v-divider
v-list-tile
v-list-tile-avatar
v-btn(icon, :to='`/users/` + page.authorId')
v-icon(color='grey') person
v-list-tile-content
v-list-tile-title.caption.grey--text Last Editor
v-list-tile-sub-title.body-2.grey--text.text--darken-3 {{ page.authorName }} #[em.caption ({{ page.authorEmail }})]
v-list-tile-action
v-list-tile-action-text {{ page.updatedAt | moment('calendar') }}
v-card.mt-3.animated.fadeInUp.wait-p4s
v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 history
span Recent History
v-spacer
v-chip(label, color='white', small).primary--text coming soon
v-timeline.mx-3(dense, clipped)
v-timeline-item(color='teal', small, v-if='page.createdAt !== page.updatedAt')
v-layout(justify-space-between)
v-flex(xs7) Page Modified by #[strong {{ page.authorName }}] #[em.caption ({{ page.authorEmail }})]
v-flex.text-xs-right(xs5).caption.grey--text.text-darken-2 {{ page.updatedAt | moment('calendar') }}
v-timeline-item(hide-dot, small)
.body-1 ...
v-btn.mx-0(outline, color='grey') View Full History
.body-1 ...
v-timeline-item(color='pink', small)
v-layout(justify-space-between)
v-flex(xs7) Page created by #[strong {{ page.creatorName }}] #[em.caption ({{ page.creatorEmail }})]
v-flex.text-xs-right(xs5).caption.grey--text.text-darken-2 {{ page.createdAt | moment('calendar') }}

v-layout(row, align-center, v-else)
v-progress-circular(indeterminate, width='2', color='grey')
.body-2.pl-3.grey--text {{ $t('common:page.loading') }}

</template>
<script>
import _ from 'lodash'
import { StatusIndicator } from 'vue-status-indicator'
import pageQuery from 'gql/admin/pages/pages-query-single.gql'
import deletePageMutation from 'gql/common/common-pages-mutation-delete.gql'
export default {
components: {
StatusIndicator
},
data() {
return {
deletePageDialog: false,
page: {},
loading: false
}
},
methods: {
async deletePage() {
this.loading = true
this.$store.commit(`loadingStart`, 'page-delete')
try {
const resp = await this.$apollo.mutate({
mutation: deletePageMutation,
variables: {
id: this.page.id
}
})
if (_.get(resp, 'data.pages.delete.responseResult.succeeded', false)) {
this.$store.commit('showNotification', {
style: 'green',
message: `Page deleted successfully.`,
icon: 'check'
})
this.$router.replace('/pages')
} else {
throw new Error(_.get(resp, 'data.pages.delete.responseResult.message', this.$t('common:error.unexpected')))
}
} catch (err) {
this.$store.commit('pushGraphError', err)
}
this.$store.commit(`loadingStop`, 'page-delete')
},
async rerenderPage() {
this.$store.commit('showNotification', {
style: 'indigo',
message: `Coming soon...`,
icon: 'directions_boat'
})
}
},
apollo: {
page: {
query: pageQuery,
variables() {
return {
id: _.toSafeInteger(this.$route.params.id)
}
},
fetchPolicy: 'network-only',
update: (data) => data.pages.single,
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
}
}
}
}
</script>

<style lang='scss'>
</style>
50 changes: 41 additions & 9 deletions client/components/admin/admin-pages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
v-layout(row wrap)
v-flex(xs12)
.admin-header
img(src='/svg/icon-file.svg', alt='Page', style='width: 80px;')
img.animated.fadeInUp(src='/svg/icon-file.svg', alt='Page', style='width: 80px;')
.admin-header-title
.headline.blue--text.text--darken-2 Pages
.subheading.grey--text Manage pages #[v-chip(label, color='primary', small).white--text coming soon]
.headline.blue--text.text--darken-2.animated.fadeInLeft Pages
.subheading.grey--text.animated.fadeInLeft.wait-p2s Manage pages
v-spacer
v-btn(color='grey', outline, @click='refresh', large)
v-btn.animated.fadeInDown.wait-p1s(color='grey', outline, @click='refresh', large)
v-icon.grey--text refresh
v-btn(color='primary', depressed, large, @click='newpage', disabled)
v-btn.animated.fadeInDown(color='primary', depressed, large, @click='newpage', disabled)
v-icon(left) add
span New Page
v-card.wiki-form.mt-3
v-card.wiki-form.mt-3.animated.fadeInUp
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `grey lighten-5`', height='80')
v-spacer
v-text-field(
Expand All @@ -29,17 +29,21 @@
hide-details
single-line
label='Locale'
:items='langs'
v-model='selectedLang'
)
v-select.ml-2(
outline
hide-details
single-line
label='Publish State'
:items='states'
v-model='selectedState'
)
v-spacer
v-divider
v-data-table(
:items='pages'
:items='filteredPages'
:headers='headers'
:search='search'
:pagination.sync='pagination'
Expand All @@ -61,11 +65,12 @@
td {{ props.item.updatedAt | moment('calendar') }}
template(slot='no-data')
v-alert.ma-3(icon='warning', :value='true', outline) No pages to display.
.text-xs-center.py-2(v-if='this.pageTotal > 1')
.text-xs-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1')
v-pagination(v-model='pagination.page', :length='pageTotal')
</template>

<script>
import _ from 'lodash'
import pagesQuery from 'gql/admin/pages/pages-query-list.gql'
export default {
Expand All @@ -82,6 +87,13 @@ export default {
{ text: 'Last Updated', value: 'updatedAt', width: 250 }
],
search: '',
selectedLang: null,
selectedState: null,
states: [
{ text: 'All Publishing States', value: null },
{ text: 'Published', value: true },
{ text: 'Not Published', value: false }
],
loading: false
}
},
Expand All @@ -91,7 +103,27 @@ export default {
return 0
}
return Math.ceil(this.pages.length / this.pagination.rowsPerPage)
return Math.ceil(this.filteredPages.length / this.pagination.rowsPerPage)
},
filteredPages () {
return _.filter(this.pages, pg => {
if (this.selectedLang !== null && this.selectedLang !== pg.locale) {
return false
}
if (this.selectedState !== null && this.selectedState !== pg.isPublished) {
return false
}
return true
})
},
langs () {
return _.concat({
text: 'All Locales',
value: null
}, _.uniqBy(this.pages, 'locale').map(pg => ({
text: pg.locale,
value: pg.locale
})))
}
},
methods: {
Expand Down

0 comments on commit 13f1729

Please sign in to comment.