Fixes undefined value of taxonomy when moving from multiple to single valued metadata.

This commit is contained in:
mateuswetah 2021-12-14 11:54:26 -03:00
parent 971042be33
commit 5569e59a0c
1 changed files with 2 additions and 1 deletions

View File

@ -155,9 +155,10 @@
methods: {
getTermsId() {
let values = [];
if (this.value && this.itemMetadatum.metadatum && this.getComponent != 'tainacan-taxonomy-tag-input') {
values = this.value.map(term => term.id).filter(term => term !== undefined);
this.valueComponent = (values.length >= 0 && this.itemMetadatum.metadatum && this.itemMetadatum.metadatum.multiple === 'no') ? values[0] : values;
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') {
values = this.value.map((term) => { return { label: term.name, value: term.id } });
this.valueComponent = values;