Skip to content

Commit

Permalink
Pro 4257 modal property (#2)
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

* Custom modal AposExportPiecesModal

* Simplify export modal

* Add operation prop

* Display module label and count in basic modal

* Lint

* Rename variable criteria to operation
  • Loading branch information
falkodev authored Aug 4, 2023
1 parent 7716679 commit 5fe2d20
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 4 deletions.
3 changes: 2 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"export": "Export",
"exporting": "Exporting"
"exporting": "Exporting",
"exportModalDescription": "You've selected {{ count }} {{ type }} for export"
}
6 changes: 3 additions & 3 deletions modules/@apostrophecms/import-export-doc-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
improve: '@apostrophecms/doc-type',

init(self) {
const criteria = {
const operation = {
action: 'export',
context: 'update',
label: 'aposImportExport:export',
Expand All @@ -17,11 +17,11 @@ module.exports = {
$ne: self.__meta.name
}
});
criteria.if = {
operation.if = {
$and: excludedTypes
};
}

self.apos.doc.addContextOperation(self.__meta.name, criteria);
self.apos.doc.addContextOperation(operation);
}
};
160 changes: 160 additions & 0 deletions ui/apos/components/AposExportPiecesModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<template>
<AposModal
:modal="modal"
class="apos-export-pieces"
v-on="{ esc: cancel }"
@no-modal="$emit('safe-close')"
@inactive="modal.active = false"
@show-modal="modal.showModal = true"
@ready="ready"
>
<template #main>
<AposModalBody>
<template #bodyMain>
<h2 class="apos-export-pieces__heading">
{{ $t('aposImportExport:export') }} {{ moduleLabel }}
</h2>
<p
class="apos-export-pieces__description"
>
{{ $t('aposImportExport:exportModalDescription', { count, type: moduleLabel }) }}
</p>
<div class="apos-export-pieces__btns">
<AposButton
class="apos-export-pieces__btn"
label="apostrophe:cancel"
@click="cancel"
/>
<AposButton
ref="exportPieces"
class="apos-export-pieces__btn"
label="aposImportExport:export"
type="primary"
@click="exportPieces"
/>
</div>
</template>
</AposModalBody>
</template>
</AposModal>
</template>

<script>
export default {
props: {
moduleName: {
type: String,
default: ''
},
count: {
type: Number,
default: 1
}
},
emits: [ 'safe-close', 'modal-result' ],
data() {
return {
modal: {
active: false,
showModal: false,
disableHeader: true
},
formValues: null
};
},
computed: {
moduleLabel() {
const moduleOptions = window.apos.modules[this.moduleName];
const label = this.count > 1 ? moduleOptions.pluralLabel : moduleOptions.label;
return this.$t(label).toLowerCase();
}
},
async mounted() {
this.modal.active = true;
},
methods: {
ready() {
this.$refs.exportPieces.$el.querySelector('button').focus();
},
exportPieces() {
this.modal.showModal = false;
const result = true;
this.$emit('modal-result', result);
},
async cancel() {
this.modal.showModal = false;
this.$emit('modal-result', false);
}
}
};
</script>

<style lang="scss" scoped>
.apos-export-pieces {
z-index: $z-index-modal;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
}
::v-deep .apos-modal__inner {
top: auto;
right: auto;
bottom: auto;
left: auto;
max-width: 700px;
height: auto;
text-align: center;
}
::v-deep .apos-modal__overlay {
.apos-modal+.apos-export-pieces & {
display: block;
}
}
::v-deep .apos-modal__body {
padding: 60px;
}
::v-deep .apos-modal__body-main {
display: flex;
flex-direction: column;
align-items: baseline;
}
.apos-export-pieces__heading {
@include type-title;
line-height: var(--a-line-tall);
margin: 0;
text-transform: capitalize;
}
.apos-export-pieces__description {
@include type-base;
max-width: 370px;
line-height: var(--a-line-tallest);
}
::v-deep .apos-schema .apos-field {
margin-bottom: $spacing-base;
}
.apos-export-pieces__btns {
display: flex;
justify-content: space-between;
margin-top: 10px;
width: 100%;
gap: 20px;
}
</style>

0 comments on commit 5fe2d20

Please sign in to comment.