diff --git a/i18n/en.json b/i18n/en.json index 8bdd34c9..e3b955f4 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -1,5 +1,12 @@ { "export": "Export", "exporting": "Exporting", - "exportModalDescription": "You've selected {{ count }} {{ type }} for export" + "exportModalDescription": "You've selected {{ count }} {{ type }} for export", + "exportModalRelatedDocumentDescription": "Include the following document types where applicable", + "exportModalSettingsLabel": "Export Settings", + "exportModalDocumentFormat": "Document Format", + "exportModalIncludeRelated": "Include related documents", + "exportModalIncludeChildren": "Include children of this page", + "exportModalIncludeRelatedSettings": "Related Documents Settings", + "exportModalNoRelatedTypes": "No Related Types" } diff --git a/index.js b/index.js index d08bf2bd..76753abe 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,45 @@ module.exports = { ns: 'aposImportExport', browser: true } + }, + + init(self) { + self.apos.asset.iconMap['apos-import-export-download-icon'] = 'Download'; + }, + + apiRoutes(self) { + return { + get: { + async related(req) { + if (!req.user) { + throw self.apos.error('forbidden'); + } + + const type = self.apos.launder.string(req.query.type); + if (!type) { + throw self.apos.error('invalid'); + } + + const { schema = [] } = self.apos.modules[type]; + const relatedTypes = schema.flatMap(searchRelationships).filter(Boolean); + + return [ ...new Set(relatedTypes) ]; + + function searchRelationships(obj) { + if (obj.type === 'relationship') { + return obj.withType; + } else if (obj.type === 'array' || obj.type === 'object') { + return obj.schema.flatMap(searchRelationships); + } else if (obj.type === 'area') { + return Object.keys(obj.options.widgets).flatMap(widget => { + const { schema = [] } = self.apos.modules[`${widget}-widget`]; + return schema.map(searchRelationships); + }); + } + } + } + } + }; } }; diff --git a/modules/@apostrophecms/import-export-doc-type/index.js b/modules/@apostrophecms/import-export-doc-type/index.js index 4dcc0c45..bd465a1f 100644 --- a/modules/@apostrophecms/import-export-doc-type/index.js +++ b/modules/@apostrophecms/import-export-doc-type/index.js @@ -8,7 +8,7 @@ module.exports = { action: 'export', context: 'update', label: 'aposImportExport:export', - modal: 'AposExportPiecesModal' + modal: 'AposExportModal' }; if (self.options.export === false) { diff --git a/modules/@apostrophecms/import-export-piece-type/index.js b/modules/@apostrophecms/import-export-piece-type/index.js index f1863255..8e533f6f 100644 --- a/modules/@apostrophecms/import-export-piece-type/index.js +++ b/modules/@apostrophecms/import-export-piece-type/index.js @@ -15,7 +15,7 @@ module.exports = { messages: { progress: 'aposImportExport:exporting' }, - modal: 'AposExportPiecesModal' + modal: 'AposExportModal' } }, group: { diff --git a/ui/apos/components/AposExportModal.vue b/ui/apos/components/AposExportModal.vue new file mode 100644 index 00000000..eaa4067b --- /dev/null +++ b/ui/apos/components/AposExportModal.vue @@ -0,0 +1,339 @@ + + + + + diff --git a/ui/apos/components/AposExportPiecesModal.vue b/ui/apos/components/AposExportPiecesModal.vue deleted file mode 100644 index 2ad9d571..00000000 --- a/ui/apos/components/AposExportPiecesModal.vue +++ /dev/null @@ -1,160 +0,0 @@ - - - - -