diff --git a/src/components/Feature/Edit/FeatureExtraForm.vue b/src/components/Feature/Edit/FeatureExtraForm.vue index e0e63f4c2059e5b68c4860769f5dd0e1c2d7899b..92aef0352bd5f01a8fd3699ef83a58855aeadfdc 100644 --- a/src/components/Feature/Edit/FeatureExtraForm.vue +++ b/src/components/Feature/Edit/FeatureExtraForm.vue @@ -63,7 +63,9 @@ </label> <Multiselect v-model="selectedPrerecordedValue" - :options="selectedPrerecordedListValues" + :options=" + selectedPrerecordedListValues[field.options[0]] ? selectedPrerecordedListValues[field.options[0]] : [] + " :options-limit="10" :allow-empty="!field.is_mandatory" track-by="label" @@ -295,26 +297,34 @@ export default { } }, prerecordedListSearchQuery(newValue) { - if (newValue) { - this.loadingPrerecordedListValues = true; - this.GET_SELECTED_PRERECORDED_LIST_VALUES({ - name: this.field.options[0], - pattern: newValue + this.loadingPrerecordedListValues = true; + this.GET_SELECTED_PRERECORDED_LIST_VALUES({ + name: this.field.options[0], + pattern: newValue + }) + .then(() => { + this.loadingPrerecordedListValues = false; }) - .then(() => { - this.loadingPrerecordedListValues = false; - }) - .catch(() => { - this.loadingPrerecordedListValues = false; - }); - } else { - this.SET_SELECTED_PRERECORDED_LIST_VALUES([]); - } + .catch(() => { + this.loadingPrerecordedListValues = false; + }); } }, created() { - console.log(this.field.value); + if (this.field.field_type === 'pre_recorded_list') { + this.loadingPrerecordedListValues = true; + this.GET_SELECTED_PRERECORDED_LIST_VALUES({ + name: this.field.options[0], + pattern: '' + }) + .then(() => { + this.loadingPrerecordedListValues = false; + }) + .catch(() => { + this.loadingPrerecordedListValues = false; + }); + } if (this.field.value) { this.selectedPrerecordedValue = { label: this.field.value }; } diff --git a/src/store/modules/feature-type.store.js b/src/store/modules/feature-type.store.js index 1b04fa29a8a0e80322642b7b73148c38be734ee0..b3c26bef03d2bd6b20cce44e6cb1967b65c096fd 100644 --- a/src/store/modules/feature-type.store.js +++ b/src/store/modules/feature-type.store.js @@ -31,7 +31,7 @@ const feature_type = { fileToImport: null, importFeatureTypeData: [], preRecordedLists: [], - selectedPrerecordedListValues: [] + selectedPrerecordedListValues: {} }, getters: { @@ -88,8 +88,8 @@ const feature_type = { SET_PRERECORDED_LISTS(state, payload) { state.preRecordedLists = payload; }, - SET_SELECTED_PRERECORDED_LIST_VALUES(state, payload) { - state.selectedPrerecordedListValues = payload.slice(0, 10).map(el => { return { label: el };}); + SET_SELECTED_PRERECORDED_LIST_VALUES(state, { name, values }) { + state.selectedPrerecordedListValues[name] = values.slice(0, 10).map(el => { return { label: el };}); } }, @@ -127,7 +127,10 @@ const feature_type = { `${this.state.configuration.VUE_APP_DJANGO_API_BASE}prerecorded-list-values/${name}/?pattern=${pattern}` ); if (response.status === 200) { - commit('SET_SELECTED_PRERECORDED_LIST_VALUES', response.data); + commit('SET_SELECTED_PRERECORDED_LIST_VALUES', { + name: name, + values: response.data + }); } } catch (err) { console.error(err);