From adc1c9f6d98eeca3929b2d064978c4371720790f Mon Sep 17 00:00:00 2001 From: weryques Date: Mon, 27 Aug 2018 15:54:49 -0300 Subject: [PATCH] Adds support to redefine status in bulk, do procedures one by one, remove close button, adds more actions for bulk actions (#18) --- .eslintrc.js | 1 + .../bulk-edition/bulk-edition-modal.vue | 186 +++++++++++++----- src/admin/components/lists/items-list.vue | 2 +- src/admin/tainacan-admin-i18n.php | 2 + .../metadata-types/textarea/Textarea.vue | 4 +- src/js/store/modules/bulk-edition/actions.js | 77 +++++++- 6 files changed, 221 insertions(+), 51 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 34a0cad16..1b44e75df 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,7 @@ module.exports = { rules: { // override/add rules settings here, such as: 'no-extra-boolean-cast': 'off', + 'vue/require-v-for-key': 'off', 'vue/no-unused-vars': 'error', 'no-console': 'warn', 'no-unused-vars': 'warn', diff --git a/src/admin/components/bulk-edition/bulk-edition-modal.vue b/src/admin/components/bulk-edition/bulk-edition-modal.vue index fb30bca13..e6cb3e8f1 100644 --- a/src/admin/components/bulk-edition/bulk-edition-modal.vue +++ b/src/admin/components/bulk-edition/bulk-edition-modal.vue @@ -16,20 +16,27 @@ class="tainacan-bulk-edition-inline-fields"> - + + + @@ -210,11 +238,17 @@ }, data() { return { + statuses: { + draft: 'draft', + publish: 'publish', + private: 'private' + }, editionCriteria: [1], editionActionsForMultiple: { remove: this.$i18n.get('remove'), redefine: this.$i18n.get('redefine'), replace: this.$i18n.get('replace'), + add: this.$i18n.get('add') }, editionActionsForNotMultiple: { redefine: this.$i18n.get('redefine'), @@ -226,6 +260,7 @@ } }, groupID: null, + dones: [false], } }, methods: { @@ -236,24 +271,46 @@ ...mapActions('bulkedition', [ 'createEditGroup', 'setValueInBulk', + 'addValueInBulk', + 'replaceValueInBulk', + 'redefineValueInBulk', + 'setStatusInBulk', ]), + finalizeProcedure(criterion){ + this.$set(this.bulkEditionProcedures[criterion], 'isDone', true); + + let index = this.editionCriteria.indexOf(criterion); + + this.dones[index] = true; + + this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', false); + }, executeBulkEditionProcedure(criterion){ let procedure = this.bulkEditionProcedures[criterion]; if(procedure.action === 'Redefine'){ this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', true); - this.setValueInBulk({ - collectionID: this.collectionID, - groupID: this.groupID, - bodyParams: { - metadatum_id: procedure.metadatumID, - value: procedure.newValue - } - }).then(() => { - this.$set(this.bulkEditionProcedures[criterion], 'isDone', true); - this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', false); - }); + if(procedure.metadatumID == 'status'){ + this.setStatusInBulk({ + collectionID: this.collectionID, + groupID: this.groupID, + bodyParams: procedure.newValue + }).then(() => { + this.finalizeProcedure(criterion) + }) + } else { + this.setValueInBulk({ + collectionID: this.collectionID, + groupID: this.groupID, + bodyParams: { + metadatum_id: procedure.metadatumID, + value: procedure.newValue + } + }).then(() => { + this.finalizeProcedure(criterion) + }); + } } }, addEditionCriterion() { @@ -272,6 +329,8 @@ isExecuting: false } }); + + this.dones.push(false) } else { this.addEditionCriterion(); } @@ -284,6 +343,7 @@ if(this.editionCriteria[criterionIndex]){ this.editionCriteria.splice(criterionIndex, 1); delete this.bulkEditionProcedures[criterion]; + this.dones.splice(criterionIndex, 1) } }, getMetadataByID(id){ @@ -291,7 +351,7 @@ return element.id == id; }); - return found; + return found ? found : {}; }, addToBulkEditionProcedures(value, key, criterion){ this.$set(this.bulkEditionProcedures[criterion], `${key}`, value); @@ -333,6 +393,33 @@ } } + .is-field-history { + + input { + color: black !important; + border: none !important; + background-color: white !important; + } + + textarea { + color: black !important; + border: none !important; + background-color: white !important; + min-height: auto !important; + } + + .select { + + &:after { + display: none !important; + } + + select { + border: none !important; + } + } + } + .tainacan-bulk-edition-field { flex-grow: 1; flex-shrink: 1; @@ -358,6 +445,11 @@ .tainacan-add-edition-criterion-button { font-size: 12px; color: $turquoise5; + text-decoration: none !important; + } + + .tainacan-add-edition-criterion-button-disabled { + cursor: not-allowed !important; } .tainacan-loader { diff --git a/src/admin/components/lists/items-list.vue b/src/admin/components/lists/items-list.vue index 280994e55..d92ca50bb 100644 --- a/src/admin/components/lists/items-list.vue +++ b/src/admin/components/lists/items-list.vue @@ -617,7 +617,7 @@ export default { component: BulkEditionModal, props: { modalTitle: this.$i18n.get('info_editing_items_in_bulk'), - totalItems: this.queryAllItemsSelected ? this.totalItems : this.selectedItemsIDs.length, + totalItems: Object.keys(this.queryAllItemsSelected).length ? this.totalItems : this.selectedItemsIDs.length, selectedForBulk: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs, objectType: this.$i18n.get('items'), metadata: this.tableMetadata, diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index 13ee8fd4c..369de026e 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -68,6 +68,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'add_one_edition_criterion' => __( 'Add one edition criterion', 'tainacan' ), 'redefine' => __( 'Redefine', 'tainacan' ), 'replace' => __( 'Replace', 'tainacan' ), + 'conclude' => __( 'Conclude', 'tainacan' ), // Wordpress Status 'publish' => __( 'Publish', 'tainacan' ), @@ -297,6 +298,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'instruction_delete_selected_taxonomies' => __( 'Delete selected taxonomies', 'tainacan' ), 'instruction_image_upload_box' => __( 'Drop an image here or click to upload.', 'tainacan' ), 'instruction_select_a_status' => __( 'Select a status:', 'tainacan' ), + 'instruction_select_a_status2' => __( 'Select a status', 'tainacan' ), 'instruction_select_a_filter_type' => __( 'Select a filter type:', 'tainacan' ), 'instruction_select_a_parent_term' => __( 'Select a parent term:', 'tainacan' ), 'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ), diff --git a/src/classes/metadata-types/textarea/Textarea.vue b/src/classes/metadata-types/textarea/Textarea.vue index 5a92d3c60..c18bb5533 100644 --- a/src/classes/metadata-types/textarea/Textarea.vue +++ b/src/classes/metadata-types/textarea/Textarea.vue @@ -1,5 +1,6 @@