Skip to content

Commit

Permalink
Fix sub pages to be shown in navigation block configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
kelanik8 committed Aug 7, 2023
1 parent 895796a commit 5cf4fd4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
</b-link>

<hr
v-if="getSubPages(navItem.options.item.pageID).length > 0"
class="my-1"
>

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -277,8 +277,11 @@ export default {
options: {
backgroundColor: '#FFFFFF00',
item: {
label: '',
url: '',
align: 'bottom',
target: 'sameTab',
displaySubPages: false,
dropdown: {
label: '',
items: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 />
Expand Down Expand Up @@ -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') },
Expand All @@ -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 : ''
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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']"
Expand Down
7 changes: 3 additions & 4 deletions lib/js/src/compose/types/page-block/navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion lib/vue/src/components/input/CInputCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default {
labels: {
type: Object,
required: true,
default: () => ({}),
},
Expand Down

0 comments on commit 5cf4fd4

Please sign in to comment.