Final adjustments to conditinal metadata section handling arrays.
This commit is contained in:
parent
f60755ed92
commit
19e1f52917
|
@ -210,7 +210,7 @@
|
|||
:is="selectedConditionalMetadatum.metadata_type_object.component"
|
||||
:forced-component-type="selectedConditionalMetadatum.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
|
||||
:item-metadatum="{ metadatum: selectedConditionalMetadatum }"
|
||||
:value="selectedConditionalValue"
|
||||
:value="Array.isArray(selectedConditionalValue) ? selectedConditionalValue[0] : selectedConditionalValue"
|
||||
:allow-new="false"
|
||||
:maxtags="1"
|
||||
@input="selectConditionalValue"
|
||||
|
|
|
@ -184,14 +184,15 @@
|
|||
this.valueComponent = (values.length > 0 && this.itemMetadatum.metadatum && this.itemMetadatum.metadatum.multiple === 'no') ? values[0] : values;
|
||||
|
||||
} else if (this.value && this.itemMetadatum.metadatum && this.getComponent == 'tainacan-taxonomy-tag-input') {
|
||||
|
||||
|
||||
// This first scenario happens in the item edition form, as the item metadata returns the terms as objects
|
||||
if ( this.value[0] && this.value[0] && this.value[0].id ) {
|
||||
values = this.value.map((term) => { return { label: term.name, value: term.id } });
|
||||
const valuesInArray = Array.isArray(this.value) ? this.value : [this.value];
|
||||
if ( valuesInArray[0] && valuesInArray[0] && valuesInArray[0].id ) {
|
||||
values = valuesInArray.map((term) => { return { label: term.name, value: term.id } });
|
||||
this.valueComponent = values;
|
||||
|
||||
// If the term is not returned as object, we're in bulk edition modal or in the metadata section condition metadata input, where value is a an array of IDs
|
||||
} else if ( this.value.length ) {
|
||||
} else if ( valuesInArray.length > 0 ) {
|
||||
this.isFetchingTerms = true;
|
||||
this.fetchTerms({
|
||||
taxonomyId: this.taxonomyId,
|
||||
|
@ -202,7 +203,7 @@
|
|||
}
|
||||
},
|
||||
all: true,
|
||||
include: this.value
|
||||
include: valuesInArray
|
||||
}).then((res) => {
|
||||
values = res.terms.map((term) => { return { label: term.name, value: term.id } });
|
||||
this.valueComponent = values;
|
||||
|
|
Loading…
Reference in New Issue