From 64559bf681135904ede6e6f727b7b0182f6c2da4 Mon Sep 17 00:00:00 2001 From: Jed Date: Thu, 9 Jan 2025 14:35:33 +0100 Subject: [PATCH] PRO 6870 Export Templates / pass module labels to AposDocContextMenu for modals (#4834) * allows to pass type to doc context menu to use for operations * checkedTypes is null by default, if it exists it's used * adds moduleLabels optional prop in AposDocContextMenu to pass to opened modals --- CHANGELOG.md | 1 + .../doc-type/ui/apos/logic/AposDocContextMenu.js | 11 ++++++++--- .../ui/apos/components/AposDocsManagerToolbar.vue | 2 +- .../page/ui/apos/logic/AposPagesManager.js | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cade67f4ec..c04558ac16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Ability to disable the color spectrum UI of a color picker * Accessibility improvement for the rich text editor Typography toolbar item. +* Adds `moduleLabels` prop to `AposDocContextMenu` to pass it to opened modals from custom operations (used by templates to define labels to display on the export modal). ### Changes diff --git a/modules/@apostrophecms/doc-type/ui/apos/logic/AposDocContextMenu.js b/modules/@apostrophecms/doc-type/ui/apos/logic/AposDocContextMenu.js index 6ff136e512..9c3c729bc1 100644 --- a/modules/@apostrophecms/doc-type/ui/apos/logic/AposDocContextMenu.js +++ b/modules/@apostrophecms/doc-type/ui/apos/logic/AposDocContextMenu.js @@ -87,6 +87,10 @@ export default { localeSwitched: { type: Boolean, default: false + }, + moduleLabels: { + type: Object, + default: null } }, emits: [ 'menu-open', 'menu-close', 'close' ], @@ -207,7 +211,8 @@ export default { ifProps = ifProps || {}; moduleIf = moduleIf || {}; - const canSeeOperation = checkIfConditions(this.doc, ifProps) && checkIfConditions(this.moduleOptions, moduleIf); + const canSeeOperation = checkIfConditions(this.doc, ifProps) && + checkIfConditions(this.moduleOptions, moduleIf); if (!canSeeOperation) { return false; @@ -219,9 +224,8 @@ export default { moduleName() { if (apos.modules[this.context.type].action === apos.modules['@apostrophecms/page'].action) { return '@apostrophecms/page'; - } else { - return this.context.type; } + return this.context.type; }, moduleOptions() { return apos.modules[this.moduleName]; @@ -446,6 +450,7 @@ export default { } const props = { moduleName: operation.moduleName || this.moduleName, + moduleLabels: this.moduleLabels, // For backwards compatibility doc, ...docProps(doc), diff --git a/modules/@apostrophecms/modal/ui/apos/components/AposDocsManagerToolbar.vue b/modules/@apostrophecms/modal/ui/apos/components/AposDocsManagerToolbar.vue index 6484ea947e..222f4b277c 100644 --- a/modules/@apostrophecms/modal/ui/apos/components/AposDocsManagerToolbar.vue +++ b/modules/@apostrophecms/modal/ui/apos/components/AposDocsManagerToolbar.vue @@ -135,7 +135,7 @@ export default { }, checkedTypes: { type: Array, - default: () => [] + default: null }, checkedCount: { type: Number, diff --git a/modules/@apostrophecms/page/ui/apos/logic/AposPagesManager.js b/modules/@apostrophecms/page/ui/apos/logic/AposPagesManager.js index 108d1d5de4..77350a931e 100644 --- a/modules/@apostrophecms/page/ui/apos/logic/AposPagesManager.js +++ b/modules/@apostrophecms/page/ui/apos/logic/AposPagesManager.js @@ -118,7 +118,8 @@ export default { return this.moduleOptions.canCreate; }, checkedTypes() { - return this.checkedDocs.map(doc => doc.type); + const types = this.checkedDocs.map(doc => doc.type); + return [ ...new Set(types) ]; } }, created() {