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

preven

t same options and allow more than 2 options
parent 37419563
No related branches found
No related tags found
No related merge requests found
...@@ -231,13 +231,23 @@ export default { ...@@ -231,13 +231,23 @@ export default {
}, },
// * create an array, because backend expects an array // * create an array, because backend expects an array
set(newValue) { set(newValue) {
this.form.options.errors = [];
this.form.options.value = this.trimWhiteSpace(newValue).split(","); this.form.options.value = this.trimWhiteSpace(newValue).split(",");
this.updateStore(); if (this.hasDuplicates(this.form.options.value)) {
this.form.options.errors = [
"Veuillez saisir des valeurs différentes",
];
} else {
this.updateStore();
}
}, },
}, },
}, },
methods: { methods: {
hasDuplicates(array) {
return new Set(array).size !== array.length;
},
fillCustomFormData(customFormData) { fillCustomFormData(customFormData) {
for (let el in customFormData) { for (let el in customFormData) {
if (el && this.form[el] && customFormData[el]) { if (el && this.form[el] && customFormData[el]) {
......
...@@ -277,10 +277,10 @@ export default { ...@@ -277,10 +277,10 @@ export default {
set(newValue) { set(newValue) {
console.log(newValue); console.log(newValue);
const newColorsStyle = { const newColorsStyle = {
colors: { colors: newValue.options.reduce((obj, key) => {
[newValue.options[0]]: "#000000", obj[key] = "#000000";
[newValue.options[1]]: "#000000", return obj;
}, }, {}),
custom_field_name: newValue.value, custom_field_name: newValue.value,
}; };
this.form.colors_style.value = newColorsStyle; this.form.colors_style.value = newColorsStyle;
......
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