Skip to content
Snippets Groups Projects
Commit 387b33ba authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmine-issue/14427' into 'develop'

REDMINE_ISSUE-14427 | Liste de valeurs pré-enregistrées

See merge request geocontrib/geocontrib-frontend!483
parents 353b7aa2 e5662d67
No related branches found
No related tags found
No related merge requests found
......@@ -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 };
}
......
......@@ -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);
......
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