diff --git a/src/classes/api/endpoints/class-tainacan-rest-item-metadata-controller.php b/src/classes/api/endpoints/class-tainacan-rest-item-metadata-controller.php index d50e20fe6..0329721a7 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-item-metadata-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-item-metadata-controller.php @@ -132,7 +132,7 @@ class REST_Item_Metadata_Controller extends REST_Controller { public function prepare_item_for_response( $item, $request ) { $item_arr = $item->_toArray(true, true); - if($request['context'] === 'edit'){ + if ($request['context'] === 'edit') { $item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_delete'] = $item->can_delete(); } diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue index 2c027cc0f..21eb9981d 100644 --- a/src/views/admin/components/edition/item-edition-form.vue +++ b/src/views/admin/components/edition/item-edition-form.vue @@ -1172,6 +1172,11 @@ export default { this.isLoading = false; + if ( wp && wp.hooks && wp.hooks.hasFilter(`tainacan_item_edition_form_submit--redirect`) ) { + window.location = wp.hooks.applyFilters(`tainacan_item_edition_form_submit--redirect`, this.item, this.form.collectionId, tainacan_plugin.admin_url); + return; + } + if (!this.$adminOptions.itemEditionMode && !this.$adminOptions.mobileAppMode) { if (!this.isOnSequenceEdit) { diff --git a/src/views/admin/components/edition/term-edition-form.vue b/src/views/admin/components/edition/term-edition-form.vue index 7bb11f7a4..689d5acb4 100644 --- a/src/views/admin/components/edition/term-edition-form.vue +++ b/src/views/admin/components/edition/term-edition-form.vue @@ -233,7 +233,9 @@ originalForm: Object, taxonomyId: '', isHierarchical: Boolean, - isTermInsertionFlow: false + isTermInsertionFlow: false, + metadatumId: [String, Number], + itemId: [String, Number] }, data() { return { @@ -308,7 +310,9 @@ this.isLoading = true; this.sendChildTerm({ taxonomyId: this.taxonomyId, - term: data + term: data, + metadatumId: this.metadatumId, + itemId: this.itemId }) .then((term) => { this.$emit('onEditionFinished', {term: term, hasChangedParent: this.hasChangedParent, initialParent: this.initialParentId }); @@ -342,7 +346,9 @@ this.isLoading = true; this.updateTerm({ taxonomyId: this.taxonomyId, - term: data + term: data, + metadatumId: this.metadatumId, + itemId: this.itemId }) .then((term) => { this.formErrors = {}; diff --git a/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue b/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue index 42558db5d..fa4a0b4ac 100644 --- a/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue +++ b/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue @@ -59,6 +59,8 @@ custom-class="tainacan-modal" :close-button-aria-label="$i18n.get('close')"> { +export const sendChildTerm = ({ commit }, { taxonomyId, term, itemId, metadatumId }) => { + + if ( itemId != undefined ) + term['item_id'] = itemId; + + if ( metadatumId != undefined ) + term['metadatum_id'] = metadatumId; + return new Promise(( resolve, reject ) => { axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, term) .then( res => { @@ -172,7 +179,14 @@ export const sendChildTerm = ({ commit }, { taxonomyId, term }) => { }); }; -export const updateTerm = ({}, { taxonomyId, term }) => { +export const updateTerm = ({}, { taxonomyId, term, itemId, metadatumId }) => { + + if ( itemId != undefined ) + term['item_id'] = itemId; + + if ( metadatumId != undefined ) + term['metadatum_id'] = metadatumId; + return new Promise(( resolve, reject ) => { axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${term.id}`, term) .then( res => { diff --git a/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php b/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php index f84a1ee5b..4fac8f1af 100644 --- a/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php +++ b/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php @@ -284,7 +284,7 @@ function tainacan_blocks_get_category_icon_script() { wp_enqueue_script( 'tainacan-blocks-register-category-icon', $TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_category_icon.js', - array('wp-blocks'), + array('wp-blocks', 'wp-element'), $TAINACAN_VERSION ); }