From bfd57dafed62ede7fb23c35ab37923217efea6fd Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 3 Oct 2022 12:18:20 -0300 Subject: [PATCH 01/12] Creates a modal for collection creation from presets. #734. --- .../modals/collection-creation-modal.vue | 208 ++++++++++++++++++ .../admin/pages/lists/collections-page.vue | 63 ++---- src/views/tainacan-i18n.php | 8 + 3 files changed, 237 insertions(+), 42 deletions(-) create mode 100644 src/views/admin/components/modals/collection-creation-modal.vue diff --git a/src/views/admin/components/modals/collection-creation-modal.vue b/src/views/admin/components/modals/collection-creation-modal.vue new file mode 100644 index 000000000..5aecc3ad5 --- /dev/null +++ b/src/views/admin/components/modals/collection-creation-modal.vue @@ -0,0 +1,208 @@ + + + + + + + + diff --git a/src/views/admin/pages/lists/collections-page.vue b/src/views/admin/pages/lists/collections-page.vue index 8d7e40c32..9258f6de0 100644 --- a/src/views/admin/pages/lists/collections-page.vue +++ b/src/views/admin/pages/lists/collections-page.vue @@ -31,17 +31,15 @@ {{ $i18n.get('info_choose_your_metadata') }} - - +
- {{ $i18n.get(metadatum_mapper.name) }} - + @click="onOpenCollectionCreationModal"> + {{ $i18n.get('label_preset_collections') }} +
+ {{ $i18n.get('info_preset_collections') }} +
@@ -285,18 +282,6 @@ {{ $i18n.get('info_choose_your_metadata') }} - - - {{ $i18n.get(metadatum_mapper.name) }} - -
import CollectionsList from '../../components/lists/collections-list.vue'; import AvailableImportersModal from '../../components/modals/available-importers-modal.vue'; +import CollectionCreationModal from '../../components/modals/collection-creation-modal.vue'; import { mapActions, mapGetters } from 'vuex'; export default { @@ -391,11 +377,6 @@ export default { } }, computed: { - metadatum_mappers: { - get() { - return this.getMetadatumMappers(); - } - }, collections() { return this.getCollections(); }, @@ -419,15 +400,6 @@ export default { created() { this.collectionsPerPage = this.$userPrefs.get('collections_per_page'); - this.isLoadingMetadatumTypes = true; - this.fetchMetadatumMappers() - .then(() => { - this.isLoadingMetadatumMappers = false; - }) - .catch(() => { - this.isLoadingMetadatumMappers = false; - }); - this.isLoadingCollectionTaxonomies = true; this.fetchCollectionTaxonomies() .then(() => { @@ -437,7 +409,8 @@ export default { this.isLoadingCollectionTaxonomies= false; }); }, - mounted(){ + mounted() { + if (this.collectionsPerPage != this.$userPrefs.get('collections_per_page')) this.collectionsPerPage = this.$userPrefs.get('collections_per_page'); if (!this.collectionsPerPage) { @@ -452,7 +425,6 @@ export default { this.$userPrefs.set('collections_order', 'asc'); } - if (this.orderBy != this.$userPrefs.get('collections_order_by')) this.orderBy = this.$userPrefs.get('collections_order_by'); if (!this.orderBy) { @@ -476,9 +448,6 @@ export default { 'getRepositoryTotalCollections', 'getCollectionTaxonomies' ]), - ...mapGetters('metadata', [ - 'getMetadatumMappers' - ]), onChangeTab(status) { this.page = 1; this.status = status; @@ -569,6 +538,16 @@ export default { closeButtonAriaLabel: this.$i18n.get('close') }); }, + onOpenCollectionCreationModal() { + this.$buefy.modal.open({ + parent: this, + component: CollectionCreationModal, + hasModalCard: true, + trapFocus: true, + customClass: 'tainacan-modal', + closeButtonAriaLabel: this.$i18n.get('close') + }); + }, searchCollections() { this.page = 1; this.loadCollections(); diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php index 15d45eec0..ffde84a4c 100644 --- a/src/views/tainacan-i18n.php +++ b/src/views/tainacan-i18n.php @@ -654,6 +654,11 @@ return apply_filters( 'tainacan-i18n', [ 'label_create_item' => __( 'Create item', 'tainacan' ), 'label_ready_to_create_item' => __( 'Ready to create this item?', 'tainacan' ), 'label_only_required' => __( 'Only required', 'tainacan' ), + 'label_create_collection_from_mapper' => __( 'Create a new collection from a mapper', 'tainacan' ), + 'label_create_collection_from_preset' => __( 'Create a preset collection', 'tainacan' ), + 'label_preset_collections' => __( 'Preset collections', 'tainacan' ), + 'label_from_a_mapper' => __( 'From a metadata mapper', 'tainacan' ), + 'label_using_a_preset' => __( 'Using a preset', 'tainacan' ), // Instructions. More complex sentences to guide user and placeholders 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), @@ -970,6 +975,9 @@ return apply_filters( 'tainacan-i18n', [ 'info_metadata_mapper_helper' => __( 'Select the corresponding metadata so they can be exposed according to the mapper', 'tainacan'), 'info_default_orderby' => __( 'These settings only affect the initial state of the items sorting. After changed, the value used will be the latest selected by the user.', 'tainacan' ), 'info_collection_thumbnail_and_header' => __( 'The thumbnail is a squared image that will represent the collection in listings. The header image is a complementary, decorative image that may or not be displayed by your theme in the items list. Keep in mind that it might be cropped.', 'tainacan'), + 'info_preset_collections' => __( 'Use mappers or standards as pre configuration', 'tainacan' ), + 'info_create_collection_from_mapper' => __( 'Have the metadata preset by an installed mapper, such as Dublin core, then set the rest manually.', 'tainacan' ), + 'info_create_collection_from_preset' => __( 'Have metadata, taxonomies, terms and related collections preset according to a standard.', 'tainacan' ), /* Activity actions */ 'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'), From 4b2fc1773c6b86c7469823a65c9eb6b752c8249a Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 4 Oct 2022 10:21:07 -0300 Subject: [PATCH 02/12] Adds filter for collections presets. #734. --- .../modals/collection-creation-modal.vue | 58 ++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/views/admin/components/modals/collection-creation-modal.vue b/src/views/admin/components/modals/collection-creation-modal.vue index 5aecc3ad5..e5782bac8 100644 --- a/src/views/admin/components/modals/collection-creation-modal.vue +++ b/src/views/admin/components/modals/collection-creation-modal.vue @@ -66,7 +66,23 @@ v-for="metadatumMapper in metadatumMappers" v-if="metadatumMapper.metadata != false" aria-role="listitem"> - {{ $i18n.get(metadatumMapper.name) }} +

{{ metadatumMapper.name }}

+

{{ metadatumMapper.description }}

+ +
+ +
+
@@ -89,29 +105,33 @@ From 927873a78e5a9e1c2f08035f2eef9f0febb3a873 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 4 Oct 2022 11:23:01 -0300 Subject: [PATCH 03/12] Fixes small flow issue in preset selection. #734. --- .../modals/collection-creation-modal.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/views/admin/components/modals/collection-creation-modal.vue b/src/views/admin/components/modals/collection-creation-modal.vue index e5782bac8..12a246fc9 100644 --- a/src/views/admin/components/modals/collection-creation-modal.vue +++ b/src/views/admin/components/modals/collection-creation-modal.vue @@ -25,8 +25,8 @@ {{ $i18n.get('label_create_collection') }} {{ $i18n.get('back') }} @@ -111,11 +111,16 @@ export default { name: 'CollectionCreationModal', data(){ return { - selectedEstrategy: this.hasPresetsHook ? undefined : 'mappers', + selectedEstrategy: 'mappers', isLoadingMetadatumMappers: true, collectionPresets: [] } }, + watch: { + hasPresetsHook() { + this.selectedEstrategy = this.hasPresetsHook ? undefined : 'mappers'; + } + }, computed: { metadatumMappers() { return this.getMetadatumMappers(); @@ -128,7 +133,7 @@ export default { }, getPresetsHook() { if (wp !== undefined && wp.hooks !== undefined) - return wp.hooks.applyFilters(`tainacan_collections_presets`, this.collectionPresets); + this.collectionPresets = wp.hooks.applyFilters(`tainacan_collections_presets`, this.collectionPresets); return this.collectionPresets; }, @@ -204,7 +209,7 @@ export default { text-align: left; padding: 15px; cursor: pointer; - max-width: 50%; + flex-basis: calc(50% - 12px); flex-grow: 1; font-size: 1em; transition: border 0.3s ease; From 0e07408852a7e6abf5bdfc5d8e729d5fe3903d66 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 4 Oct 2022 11:36:23 -0300 Subject: [PATCH 04/12] Perform request to absolute endpoint. #734. --- .../modals/collection-creation-modal.vue | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/views/admin/components/modals/collection-creation-modal.vue b/src/views/admin/components/modals/collection-creation-modal.vue index 12a246fc9..920548288 100644 --- a/src/views/admin/components/modals/collection-creation-modal.vue +++ b/src/views/admin/components/modals/collection-creation-modal.vue @@ -105,7 +105,7 @@