diff --git a/src/components/feature_type/FeatureTypeCustomForm.vue b/src/components/feature_type/FeatureTypeCustomForm.vue index 5372073ee270dca4dba201cfdf927b089512c8f8..30b0a1e8014f0d788bc73e8d066b63de73315e2f 100644 --- a/src/components/feature_type/FeatureTypeCustomForm.vue +++ b/src/components/feature_type/FeatureTypeCustomForm.vue @@ -231,13 +231,23 @@ export default { }, // * create an array, because backend expects an array set(newValue) { + this.form.options.errors = []; 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: { + hasDuplicates(array) { + return new Set(array).size !== array.length; + }, fillCustomFormData(customFormData) { for (let el in customFormData) { if (el && this.form[el] && customFormData[el]) { diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 889b249c57ac0a46328cf403f68e8b9c612cdd3f..6a1cefd4068145799a5f4db9a25182acad1d6e35 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -277,10 +277,10 @@ export default { set(newValue) { console.log(newValue); const newColorsStyle = { - colors: { - [newValue.options[0]]: "#000000", - [newValue.options[1]]: "#000000", - }, + colors: newValue.options.reduce((obj, key) => { + obj[key] = "#000000"; + return obj; + }, {}), custom_field_name: newValue.value, }; this.form.colors_style.value = newColorsStyle;