diff --git a/src/components/Collective/NcActionCollectiveActions.vue b/src/components/Collective/NcActionCollectiveActions.vue index 600ede43a..6def4d469 100644 --- a/src/components/Collective/NcActionCollectiveActions.vue +++ b/src/components/Collective/NcActionCollectiveActions.vue @@ -140,7 +140,7 @@ export default { 'isCollectiveAdmin', ]), - ...mapState(usePagesStore, ['pagesTreeWalk']), + ...mapState(usePagesStore, ['pagesTreeWalkForCollective']), circleLink() { return generateUrl('/apps/contacts/direct/circle/' + this.collective.circleId) @@ -160,7 +160,7 @@ export default { return null } - const pageIds = this.pagesTreeWalk().map((p) => p.id) + const pageIds = this.pagesTreeWalkForCollective(this.collective).map((p) => p.id) return { title: collectiveExtraAction.title ?? t('collectives', 'Extra action'), click: () => collectiveExtraAction.click(pageIds) ?? function() {}, diff --git a/src/stores/pages.js b/src/stores/pages.js index 6a449f68e..fbb775d21 100644 --- a/src/stores/pages.js +++ b/src/stores/pages.js @@ -305,10 +305,29 @@ export const usePagesStore = defineStore('pages', { } }, + visibleSubpagesForCollective(state) { + return (collective, parentId) => { + return state.sortedSubpagesForCollective(collective, parentId) + } + }, + visibleSubpages: (state) => (parentId) => { return state.sortedSubpages(parentId) }, + pagesTreeWalkForCollective(state) { + return (collective, parentId = 0) => { + const pages = [] + for (const page of state.visibleSubpagesForCollective(collective, parentId)) { + pages.push(page) + for (const subpage of state.pagesTreeWalkForCollective(collective, page.id)) { + pages.push(subpage) + } + } + return pages + } + }, + pagesTreeWalk: (state) => (parentId = 0) => { const pages = [] for (const page of state.visibleSubpages(parentId)) { @@ -352,6 +371,9 @@ export const usePagesStore = defineStore('pages', { sortByDefault() { const collectivesStore = useCollectivesStore() + if (!collectivesStore.currentCollective) { + return 'byOrder' + } return sortOrders.pageOrdersByNumber[collectivesStore.currentCollective.userPageOrder] },