Skip to content

Commit

Permalink
Export: add context menu and batch operation (#1)
Browse files Browse the repository at this point in the history
* Export: add context menu and batch operation

* Export: add exclusion

* Improve readibility

* Improve readibility
  • Loading branch information
falkodev committed Aug 2, 2023
1 parent 16edf70 commit 7716679
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
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' ]
}
}
};
}
};

0 comments on commit 7716679

Please sign in to comment.