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

update colorsStyleList not only at update of customForm

parent f41f9ba0
Branches
Tags
1 merge request!138REDMINE_ISSUE-12426
......@@ -6,6 +6,11 @@ axios.defaults.headers.common['X-CSRFToken'] = (name => {
return (value !== null) ? unescape(value[1]) : null;
})('csrftoken');
const getColorsStyles = (customForms) => customForms.filter(customForm => customForm.options && customForm.options.length).map(el => {
//* in dropdown, value is the name and name is the label to be displayed, could be changed...
return { value: el.name, name: el.label, options: el.options }
});
const feature_type = {
namespaced: true,
......@@ -36,26 +41,27 @@ const feature_type = {
},
SET_CUSTOM_FORMS(state, customForms) {
state.customForms = customForms;
state.colorsStyleList = getColorsStyles(state.customForms);
},
ADD_CUSTOM_FORM(state, customForm) {
state.customForms = [...state.customForms, customForm];
state.colorsStyleList = getColorsStyles(state.customForms);
},
UPDATE_CUSTOM_FORM(state, payload) {
const index = state.customForms.findIndex((el) => el.dataKey === payload.dataKey);
if (index !== -1) {
state.customForms[index] = payload;
//* trigger update of available options for colors style in feature_type_edit
state.colorsStyleList = state.customForms.filter(cust => cust.options && cust.options.length).map(el => {
//* in dropdown, value is the name and name is the label to be displayed, could be changed...
return { value: el.name, name: el.label, options: el.options }
})
//* trigger update of available options for colors style in feature_type_edit (getters not working)
state.colorsStyleList = getColorsStyles(state.customForms);
}
},
REMOVE_CUSTOM_FORM(state, payload) {
state.customForms = state.customForms.filter(form => form.dataKey !== payload);
state.colorsStyleList = getColorsStyles(state.customForms);
},
EMPTY_CUSTOM_FORMS(state) {
state.customForms = [];
state.colorsStyleList = [];
},
SET_IMPORT_FEATURE_TYPES_DATA(state, payload) {
state.importFeatureTypeData = payload;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment