Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pro 4260 export modal #4

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"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\nwhere applicable",
falkodev marked this conversation as resolved.
Show resolved Hide resolved
"exportModalSettingsLabel": "Export Settings",
"exportModalDocumentFormat": "Document Format",
"exportModalIncludeRelated": "Include related documents",
"exportModalIncludeRelatedSettings": "Related Documents Settings",
"exportModalNoRelatedTypes": "No Related Types"
}
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@ module.exports = {
ns: 'aposImportExport',
browser: true
}
},

apiRoutes(self) {
return {
get: {
async related(req) {
if (!req.user) {
throw self.apos.error('forbidden');
}
const moduleName = self.apos.launder.string(req.query.moduleName);
if (!moduleName) {
return { success: false };
falkodev marked this conversation as resolved.
Show resolved Hide resolved
}
const schema = self.apos.modules[moduleName].schema;
falkodev marked this conversation as resolved.
Show resolved Hide resolved

return [ ...new Set(schema.reduce((acc, cur) => {
falkodev marked this conversation as resolved.
Show resolved Hide resolved
if (cur.type === 'relationship') {
acc.push(cur.withType);
} else if (cur.type === 'array' || cur.type === 'object') {
for (const field of cur.schema) {
if (field.type === 'relationship') {
acc.push(field.withType);
}
}
// } else if (cur.type === 'area') {

}

return acc;
}, [])) ];
}
}
};
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/import-export-doc-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
action: 'export',
context: 'update',
label: 'aposImportExport:export',
modal: 'AposExportPiecesModal'
modal: 'AposExportModal'
};

if (self.options.export === false) {
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/import-export-piece-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
messages: {
progress: 'aposImportExport:exporting'
},
modal: 'AposExportPiecesModal'
modal: 'AposExportModal'
}
},
group: {
Expand Down
Loading