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

prevent customForm being added twice at edit

parent 51afea7e
No related branches found
No related tags found
1 merge request!138REDMINE_ISSUE-12426
...@@ -340,11 +340,19 @@ export default { ...@@ -340,11 +340,19 @@ export default {
}, },
addCustomForm(customForm) { addCustomForm(customForm) {
if (
customForm &&
this.customForms.some((cf) => cf.name === customForm.name)
) {
//* abort if customForm already exists (because watcher can update again)
return;
}
this.dataKey += 1; // * increment counter for key in v-for this.dataKey += 1; // * increment counter for key in v-for
let newCustomForm = { let newCustomForm = {
dataKey: this.dataKey, dataKey: this.dataKey,
}; };
if (customForm) { if (customForm) {
//* if adding an existing customForm -> add its property to newCustomForm containing only dataKey
newCustomForm = { ...newCustomForm, ...customForm }; newCustomForm = { ...newCustomForm, ...customForm };
} }
this.$store.commit("feature_type/ADD_CUSTOM_FORM", newCustomForm); // * create an object with the counter in store this.$store.commit("feature_type/ADD_CUSTOM_FORM", newCustomForm); // * create an object with the counter in store
......
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