diff --git a/src/components/Feature/Edit/FeatureExtraForm.vue b/src/components/Feature/Edit/FeatureExtraForm.vue index b958d7a2322bccc032d9e5c752e118a060817158..8315eb670b0604f9b484bb0bb5e0b213c82c4820 100644 --- a/src/components/Feature/Edit/FeatureExtraForm.vue +++ b/src/components/Feature/Edit/FeatureExtraForm.vue @@ -375,9 +375,15 @@ export default { }, watch: { - 'field.value': function(newValue) { + 'field.value': function(newValue, oldValue) { if (newValue) { this.error = null; + // In fast edition, prerecordedlist is not updated, thus the value stay the same + // in this case we renitialize the field. This doesn't impact usual behavior if user reselect the same option + if (this.field.field_type === 'pre_recorded_list' && + newValue.label && newValue.label === oldValue.label) { + this.initPrerecordedField(); + } } }, @@ -398,22 +404,9 @@ export default { created() { if (this.field) { - const { field_type, options, value } = this.field; + const { field_type, value } = this.field; if (field_type === 'pre_recorded_list') { - this.loadingPrerecordedListValues = true; - this.GET_SELECTED_PRERECORDED_LIST_VALUES({ - name: options[0], - pattern: '' - }) - .then(() => { - this.loadingPrerecordedListValues = false; - }) - .catch(() => { - this.loadingPrerecordedListValues = false; - }); - if (value) { - this.selectedPrerecordedValue = { label: value.label ? value.label : value }; - } + this.initPrerecordedField(); } else if (field_type === 'multi_choices_list' && value) { this.selectedMultipleCheckbox = value; } @@ -436,6 +429,24 @@ export default { 'SET_EXTRA_FORMS', ]), + initPrerecordedField() { + const { options, value } = this.field; + this.loadingPrerecordedListValues = true; + this.GET_SELECTED_PRERECORDED_LIST_VALUES({ + name: options[0], + pattern: '' + }) + .then(() => { + this.loadingPrerecordedListValues = false; + }) + .catch(() => { + this.loadingPrerecordedListValues = false; + }); + if (value) { + this.selectedPrerecordedValue = { label: value.label ? value.label : value }; + } + }, + updateStore_extra_form(evt) { if (this.field) { let newValue;