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 cc264ea60..ac77898c4 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
@@ -291,7 +291,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
$endpoint_args['parent_meta_id'] = [
'type' => 'array/string/object/integer',
'items' => ['type' => 'array/string/object/integer'],
- 'description' => __('The parent meta ID for group children item metadatas')
+ 'description' => __('The parent meta ID for the item metadata children group')
];
}
diff --git a/src/classes/generic-background-process/class-tainacan-bulk-edit-process.php b/src/classes/generic-background-process/class-tainacan-bulk-edit-process.php
index 9666eb58b..e72008e2a 100644
--- a/src/classes/generic-background-process/class-tainacan-bulk-edit-process.php
+++ b/src/classes/generic-background-process/class-tainacan-bulk-edit-process.php
@@ -325,7 +325,7 @@ class Bulk_Edit_Process extends Generic_Process {
}
}
- $this->add_error_log( __('Not possible to copy permission for different types', 'tainacan') );
+ $this->add_error_log( __('Not possible to copy metadata values of different types', 'tainacan') );
return false;
}
diff --git a/src/views/admin/components/metadata-types/compound/Compound.vue b/src/views/admin/components/metadata-types/compound/Compound.vue
index 8ad3280f8..8441e3c8b 100644
--- a/src/views/admin/components/metadata-types/compound/Compound.vue
+++ b/src/views/admin/components/metadata-types/compound/Compound.vue
@@ -84,7 +84,10 @@
- {{ $i18n.get('label_add_value') }}
+ {{ $i18n.get('label_add_value') }}
+
+
+
@@ -102,6 +105,7 @@
data() {
return {
isRemovingGroup: false,
+ isCreatingGroup: false,
children: [],
collapseAllChildren: true,
childItemMetadataGroups: []
@@ -226,34 +230,38 @@
this.childItemMetadataGroups[groupIndex][index].collapse = !event;
},
addGroup() {
- // Create a new placeholder parent_meta_id group here.
- let newEmptyGroup = [];
-
- if (this.itemMetadatum &&
- this.itemMetadatum.metadatum &&
- this.itemMetadatum.metadatum.metadata_type_options &&
- this.itemMetadatum.metadatum.metadata_type_options.children_objects.length > 0
- ) {
- for (let child of this.itemMetadatum.metadatum.metadata_type_options.children_objects) {
- let childObject = {
- item: this.itemMetadatum.item,
- metadatum: child,
- parent_meta_id: 0,
- value: '',
- value_as_html: '',
- value_as_string: '',
- collapse: false
- };
- newEmptyGroup.push(childObject)
- }
- }
+ this.isCreatingGroup = true;
+
// Sends value to api so we can obtain the parent_meta_id
- eventBusItemMetadata.$emit('input', {
+ eventBusItemMetadata.fetchCompoundFirstParentMetaId({
itemId: this.itemMetadatum.item.id,
- metadatumId: newEmptyGroup[0].metadatum.id,
- values: newEmptyGroup[0].value,
- parentMetaId: newEmptyGroup[0].parent_meta_id
+ metadatumId: this.itemMetadatum.metadatum.id
+ }).then((parentMetaId) => {
+
+ // Create a new placeholder parent_meta_id group here.
+ let newEmptyGroup = [];
+
+ if (this.itemMetadatum &&
+ this.itemMetadatum.metadatum &&
+ this.itemMetadatum.metadatum.metadata_type_options &&
+ this.itemMetadatum.metadatum.metadata_type_options.children_objects.length > 0
+ ) {
+ for (let child of this.itemMetadatum.metadatum.metadata_type_options.children_objects) {
+ let childObject = {
+ item: this.itemMetadatum.item,
+ metadatum: child,
+ parent_meta_id: parentMetaId,
+ value: '',
+ value_as_html: '',
+ value_as_string: '',
+ collapse: false
+ };
+ newEmptyGroup.push(childObject)
+ }
+ }
+
+ this.isCreatingGroup = true;
});
},
removeGroup(groupIndex) {
diff --git a/src/views/admin/components/metadata-types/compound/class-tainacan-compound.php b/src/views/admin/components/metadata-types/compound/class-tainacan-compound.php
index 2a0209d26..532e0d493 100644
--- a/src/views/admin/components/metadata-types/compound/class-tainacan-compound.php
+++ b/src/views/admin/components/metadata-types/compound/class-tainacan-compound.php
@@ -16,7 +16,7 @@ class Compound extends Metadata_Type {
// call metadatum type constructor
parent::__construct();
$this->set_name( __('Compound', 'tainacan') );
- $this->set_description( __('A compound metadata can have different types with groups of values.', 'tainacan') );
+ $this->set_description( __('A compound metadatum can have groups of values of different types.', 'tainacan') );
$this->set_primitive_type('compound');
$this->set_component('tainacan-compound');
$this->set_form_component('tainacan-form-compound');
diff --git a/src/views/admin/js/event-bus-item-metadata.js b/src/views/admin/js/event-bus-item-metadata.js
index a4302e7b6..b54bf137f 100644
--- a/src/views/admin/js/event-bus-item-metadata.js
+++ b/src/views/admin/js/event-bus-item-metadata.js
@@ -87,6 +87,9 @@ export const eventBusItemMetadata = new Vue({
},
clearAllErrors() {
this.errors = [];
+ },
+ fetchCompoundFirstParentMetaId({ itemId, metadatumId }) {
+ return this.$store.dispatch('item/fetchCompoundFirstParentMetaId', { item_id: itemId, metadatum_id: metadatumId });
}
}
});
diff --git a/src/views/admin/js/store/modules/item/actions.js b/src/views/admin/js/store/modules/item/actions.js
index 83bf09217..d88ab1ad8 100644
--- a/src/views/admin/js/store/modules/item/actions.js
+++ b/src/views/admin/js/store/modules/item/actions.js
@@ -40,6 +40,27 @@ export const fetchItemMetadata = ({ commit }, item_id) => {
});
};
+
+// Actions related to Item's metadata
+export const fetchCompoundFirstParentMetaId = ({ commit }, { item_id, metadatum_id }) => {
+
+ return new Promise((resolve, reject) => {
+ axios.tainacan.patch(`/item/${item_id}/metadata/${metadatum_id}`, { value: [] })
+ .then( res => {
+ const parentMetaId = res.data.parent_meta_id;
+ resolve(parentMetaId);
+ })
+ .catch( error => {
+ reject({
+ error: error.response.data.errors,
+ error_message: error.response.data.error_message,
+ item_metadata: error.response.data.item_metadata
+ });
+ })
+ });
+};
+
+
export const deleteItemMetadataGroup = ({ commit }, { item_id, metadatum_id, parent_meta_id }) => {
return new Promise((resolve) => {
diff --git a/src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js b/src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js
index 9983da8fa..dd41a058d 100644
--- a/src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js
+++ b/src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js
@@ -483,7 +483,7 @@ registerBlockType('tainacan/faceted-search', {
/>
{
startWithFiltersHidden = isChecked;
@@ -493,7 +493,7 @@ registerBlockType('tainacan/faceted-search', {
/>
{
filtersAsModal = isChecked;