diff --git a/src/views/admin/components/metadata-types/date/Date.vue b/src/views/admin/components/metadata-types/date/Date.vue index 713daa8b6..d6b5dca84 100644 --- a/src/views/admin/components/metadata-types/date/Date.vue +++ b/src/views/admin/components/metadata-types/date/Date.vue @@ -57,7 +57,7 @@ }, methods: { onInput: _.debounce(function ($event) { - // Emty dates don't need to be validated, they remove the metadata + // Empty dates don't need to be validated, they remove the metadata if ($event.target.value != '') { let dateISO = ''; @@ -75,7 +75,7 @@ this.$emit('input', dateISO); } else { - this.$emit('input', [null]); + this.$emit('input', ''); } }, 300), onBlur() { diff --git a/src/views/admin/components/metadata-types/tainacan-form-item.vue b/src/views/admin/components/metadata-types/tainacan-form-item.vue index 20098f4ab..ee73690cf 100644 --- a/src/views/admin/components/metadata-types/tainacan-form-item.vue +++ b/src/views/admin/components/metadata-types/tainacan-form-item.vue @@ -180,7 +180,6 @@ // This routine avoids calling the API if the value did not changed switch(this.itemMetadatum.value.constructor.name) { - // Multivalored Metadata requires checking the whole array case 'Array': { @@ -188,11 +187,11 @@ let currentValues = []; // An array of terms - if (this.values.length && this.values[0].constructor.name == 'Object') + if (this.values.length && this.values[0] && this.values[0].constructor.name == 'Object') currentValues = this.values.map(term => term.value) else currentValues = this.values; - + if (Array.isArray(currentValues)) { for (let value of currentValues) { let foundIndex = this.itemMetadatum.value.findIndex(element => value == element.id); diff --git a/src/views/admin/js/event-bus-item-metadata.js b/src/views/admin/js/event-bus-item-metadata.js index b06c015f1..c38ff5b98 100644 --- a/src/views/admin/js/event-bus-item-metadata.js +++ b/src/views/admin/js/event-bus-item-metadata.js @@ -31,7 +31,7 @@ export const eventBusItemMetadata = new Vue({ this.$emit('isUpdatingValue', true); - if (values.length > 0 && values[0].value) { + if (values.length > 0 && values[0] && values[0].value) { let onlyValues = values.map((aValueObject) => aValueObject.value); values = onlyValues; }