Browse Source

stage: Paths selector

pull/7619/head
Ruslan Semak 2 months ago
parent
commit
2570dff99b
1 changed files with 63 additions and 6 deletions
  1. 69
      client/components/admin/admin-pages.vue

69
client/components/admin/admin-pages.vue

@ -28,6 +28,16 @@
dense dense
style='max-width: 400px;' style='max-width: 400px;'
) )
v-select.ml-2(
solo
flat
hide-details
dense
label='Paths'
:items='paths'
v-model='selectedPath'
style='max-width: 250px;'
)
v-spacer v-spacer
v-select.ml-2( v-select.ml-2(
solo solo
@ -74,7 +84,22 @@
span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }} span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
td {{ props.item.createdAt | moment('calendar') }} td {{ props.item.createdAt | moment('calendar') }}
td {{ props.item.updatedAt | moment('calendar') }} td {{ props.item.updatedAt | moment('calendar') }}
td {{ props.item.orderPriority }}
td
v-edit-dialog(
:return-value.sync='props.item.orderPriority'
@save='savePriority(props.item)'
large
)
div {{ props.item.orderPriority }}
template(v-slot:input)
v-text-field(
v-model='props.item.orderPriority'
type='number'
label='Edit Priority'
single-line
autofocus
:rules='[v => !!v || "Priority is required", v => v >= 0 || "Must be positive"]'
)
template(slot='no-data') template(slot='no-data')
v-alert.ma-3(icon='mdi-alert', :value='true', outlined) No pages to display. v-alert.ma-3(icon='mdi-alert', :value='true', outlined) No pages to display.
.text-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1') .text-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1')
@ -98,22 +123,27 @@ export default {
{ text: 'Path', value: 'path' }, { text: 'Path', value: 'path' },
{ text: 'Created', value: 'createdAt', width: 250 }, { text: 'Created', value: 'createdAt', width: 250 },
{ text: 'Last Updated', value: 'updatedAt', width: 250 }, { text: 'Last Updated', value: 'updatedAt', width: 250 },
{ text: 'Order Priority', value: 'orderPriority' }
{ text: 'Order Priority', value: 'orderPriority', width: 150 }
], ],
search: '', search: '',
selectedLang: null, selectedLang: null,
selectedState: null, selectedState: null,
selectedPath: null,
states: [ states: [
{ text: 'All Publishing States', value: null }, { text: 'All Publishing States', value: null },
{ text: 'Published', value: true }, { text: 'Published', value: true },
{ text: 'Not Published', value: false } { text: 'Not Published', value: false }
], ],
paths: [],
loading: false loading: false
} }
}, },
computed: { computed: {
filteredPages () { filteredPages () {
return _.filter(this.pages, pg => { return _.filter(this.pages, pg => {
if (this.selectedPath !== null && !pg.path.startsWith(this.selectedPath)) {
return false
}
if (this.selectedLang !== null && this.selectedLang !== pg.locale) { if (this.selectedLang !== null && this.selectedLang !== pg.locale) {
return false return false
} }
@ -141,6 +171,16 @@ export default {
style: 'success', style: 'success',
icon: 'cached' icon: 'cached'
}) })
this.paths = [{ text: 'aaa', value: null }]
},
updatePathSelector(pages) {
const paths = Array.from(new Set(pages.filter(p => p.path.includes('/')).map(p => p.path.split('/')[0])))
this.paths = [
{ text: 'Select path', value: null },
...paths.sort().map(p => ({ text: p, value: p }))
]
}, },
newpage() { newpage() {
this.pageSelectorShown = true this.pageSelectorShown = true
@ -151,11 +191,17 @@ export default {
pages: { pages: {
query: pagesQuery, query: pagesQuery,
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
update: (data) => data.pages.list.map(p => {
p.orderPriority = Math.round(Math.random() * 100)
update: function (data) {
const pages = data.pages.list.map(p => {
console.log('randomed')
p.orderPriority = Math.round(Math.random() * 100)
return p
})
return p
}),
this.updatePathSelector(pages)
return pages
},
watchLoading (isLoading) { watchLoading (isLoading) {
this.loading = isLoading this.loading = isLoading
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh') this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
@ -172,4 +218,15 @@ export default {
align-items: center; align-items: center;
font-family: 'Roboto Mono', monospace; font-family: 'Roboto Mono', monospace;
} }
.v-edit-dialog {
display: flex;
align-items: center;
justify-content: center;
min-height: 36px;
&__input {
padding: 16px;
}
}
</style> </style>
Loading…
Cancel
Save