Skip to content
Snippets Groups Projects
Commit ee1cc30f authored by Timothee P's avatar Timothee P :sunflower:
Browse files

refactorate prerecordedfield initialization & reinit in fast edition mode

parent ca1d1678
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment