Fix sub pages to be shown in navigation block configurator

This commit is contained in:
Kelani Tolulope
2023-08-07 13:10:00 +01:00
parent 895796a475
commit 5cf4fd4831
6 changed files with 37 additions and 33 deletions
@@ -90,6 +90,7 @@
</b-link>
<hr
v-if="getSubPages(navItem.options.item.pageID).length > 0"
class="my-1"
>
@@ -140,8 +141,8 @@ export default {
return (navItem.type === 'compose' && navItem.options.item.displaySubPages)
},
getSubPages (selfID) {
return this.pages.filter(value => value.selfID === selfID && value.moduleID === NoID) || []
getSubPages (pageID) {
return this.pages.filter(value => value.selfID === pageID && value.moduleID === NoID) || []
},
selectTargetOption (target) {
@@ -73,7 +73,7 @@
<div class="mb-3 mt-2">
<div class="d-flex align-items-center mb-4">
<h5 class="text-primary mb-0">
<h5 class="mb-0">
{{ $t("navigation.navigationItems") }}
</h5>
</div>
@@ -149,11 +149,11 @@
class="w-100"
/>
</td>
<td class="align-middle text-center">
<b-form-checkbox
<td class="d-flex align-items-center justify-content-center">
<c-input-checkbox
v-model="item.options.enabled"
switch
class="mb-0"
:labels="{}"
/>
</td>
<td class="align-middle">
@@ -277,8 +277,11 @@ export default {
options: {
backgroundColor: '#FFFFFF00',
item: {
label: '',
url: '',
align: 'bottom',
target: 'sameTab',
displaySubPages: false,
dropdown: {
label: '',
items: [],
@@ -15,7 +15,7 @@
key="pageID"
v-model="options.item.pageID"
:placeholder="$t('navigation.none')"
:options="tree"
:options="pageList"
append-to-body
:get-option-key="getOptionKey"
label="title"
@@ -37,19 +37,21 @@
</b-form-group>
</td>
<td
v-if="selectedPageChildren(options.item.pageID)"
v-if="selectedPageChildren(options.item.pageID).length > 0"
cols="12"
sm="6"
class="align-middle text-center"
>
<b-form-group class="m-0">
<b-form-checkbox
<b-form-group
:label="$t('navigation.displaySubPages')"
label-class="text-nowrap"
class="d-flex align-items-center justify-content-center mb-0"
>
<c-input-checkbox
v-model="options.item.displaySubPages"
switch
size="sm"
>
{{ $t('navigation.displaySubPages') }}
</b-form-checkbox>
/>
</b-form-group>
</td>
<td />
@@ -78,7 +80,11 @@ export default {
data () {
return {
tree: [],
pageList: [],
checkboxLabel: {
on: this.$t('general:label.yes'),
off: this.$t('general:label.no'),
},
targetOptions: [
{ value: 'sameTab', text: this.$t('navigation.sameTab') },
{ value: 'newTab', text: this.$t('navigation.newTab') },
@@ -87,28 +93,27 @@ export default {
},
created () {
this.loadTree()
this.loadPages()
},
methods: {
selectedPageChildren (pageID) {
const tree = this.tree ? this.tree.find(t => t.pageID === pageID) : {}
return tree && tree.children ? tree.children.length > 0 : false
return this.pageList.filter(value => value.selfID === pageID && value.moduleID === NoID) || []
},
loadTree () {
loadPages () {
const { namespaceID } = this.namespace
this.$ComposeAPI
.pageList({ namespaceID, sort: 'title' })
.then(({ set: tree }) => {
this.tree = tree.map(p => new compose.Page(p)).filter(p => p.moduleID === NoID)
.then(({ set: pages }) => {
this.pageList = pages.map(p => new compose.Page(p)).filter(p => p.moduleID === NoID)
})
.catch(this.toastErrorHandler(this.$t('notification:page.loadFailed')))
},
updateLabelValue (pageID) {
if (!this.options.item.label) {
const composePage = this.tree.find(t => t.pageID === pageID)
const composePage = this.pageList.find(t => t.pageID === pageID)
this.options.item.label = composePage ? composePage.title : ''
}
},
@@ -50,10 +50,7 @@
<th style="min-width: 200px;">
{{ $t("navigation.url") }}
</th>
<th
class="text-center"
style="min-width: 200px;"
>
<th style="min-width: 200px;">
{{ $t('navigation.openIn') }}
</th>
<th
@@ -96,8 +93,8 @@
</td>
<td class="align-middle text-center">
<b-form-group class="mb-0">
<b-form-checkbox
<b-form-group class="d-flex align-items-center justify-content-center mb-0">
<c-input-checkbox
v-model="item.delimiter"
switch
size="sm"
@@ -118,7 +115,7 @@
<b-button
variant="primary"
class="text-decoration-none"
@click="options.item.dropdown.items.push({ text: '', url: '', target: 'sameTab' })"
@click="options.item.dropdown.items.push({ text: '', url: '', target: 'sameTab', delimiter: false })"
>
<font-awesome-icon
:icon="['fas', 'plus']"
@@ -39,13 +39,12 @@ export class PageBlockNavigation extends PageBlock {
applyOptions (o?: Partial<Options>): void {
if (!o) return
Apply(this.options, o, String, 'magnifyOption')
this.options.navigationItems = (o.navigationItems || []).map(f => new NavigationItem(f))
if (o.display) {
this.options.display = o.display
}
this.options.display = { ...this.options.display, ...o.display }
Apply(this.options, o, String, 'magnifyOption')
}
static makeNavigationItem (item?: NavigationItemInput): NavigationItem {
@@ -38,7 +38,6 @@ export default {
labels: {
type: Object,
required: true,
default: () => ({}),
},