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

Export: add context menu and batch operation #1

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img src="https://raw.githubusercontent.com/apostrophecms/apostrophe/main/logo.svg" alt="ApostropheCMS logo" width="80" height="80">

<h1>Apostrophe Module Template</h1>
<h1>Apostrophe Import Export Module</h1>
<p>
<a aria-label="Apostrophe logo" href="https://v3.docs.apostrophecms.org">
<img src="https://img.shields.io/badge/MADE%20FOR%20Apostrophe%203-000000.svg?style=for-the-badge&logo=Apostrophe&labelColor=6516dd">
Expand Down
4 changes: 4 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"export": "Export",
"exporting": "Exporting"
}
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ module.exports = {
bundle: {
directory: 'modules',
modules: getBundleModuleNames()
},

options: {
name: '@apostrophecms/import-export',
i18n: {
ns: 'aposImportExport',
browser: true
}
}
};

Expand Down
27 changes: 27 additions & 0 deletions modules/@apostrophecms/import-export-doc-type/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const excludedTypes = [];

module.exports = {
improve: '@apostrophecms/doc-type',

init(self) {
const criteria = {
action: 'export',
context: 'update',
label: 'aposImportExport:export',
modal: 'AposExportPiecesModal'
};

if (self.options.export === false) {
excludedTypes.push({
type: {
$ne: self.__meta.name
}
});
criteria.if = {
$and: excludedTypes
};
}

self.apos.doc.addContextOperation(self.__meta.name, criteria);
}
};
29 changes: 29 additions & 0 deletions modules/@apostrophecms/import-export-piece-type/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
improve: '@apostrophecms/piece-type',

cascades: [ 'batchOperations' ],

batchOperations(self) {
if (self.options.export === false) {
return;
}

return {
add: {
export: {
label: 'aposImportExport:export',
messages: {
progress: 'aposImportExport:exporting'
},
modal: 'AposExportPiecesModal'
}
},
group: {
more: {
icon: 'dots-vertical-icon',
operations: [ 'export' ]
}
}
};
}
};