diff --git a/src/components/FeatureType/FeatureTypeCustomForm.vue b/src/components/FeatureType/FeatureTypeCustomForm.vue index 849b18bb709164983698fa31c07b9a2776f9f71a..5b94ef231a6d0134164883a41bf371bc0ebe9d8c 100644 --- a/src/components/FeatureType/FeatureTypeCustomForm.vue +++ b/src/components/FeatureType/FeatureTypeCustomForm.vue @@ -391,6 +391,22 @@ export default { this.updateStore(); }, + updateStore() { + const data = { + dataKey: this.customForm.dataKey, + isMandatory: this.form.isFieldMandatory, + label: this.form.label.value, + name: this.form.name.value, + position: this.form.position.value, + field_type: this.form.field_type.value, + options: this.form.options.value, + }; + this.$store.commit('feature-type/UPDATE_CUSTOM_FORM', data); + if (this.customForm.name === this.selectedColorStyle ) { + this.$emit('update', this.form.options.value); + } + }, + hasDuplicateOptions() { this.form.options.errors = []; const isDup = @@ -421,6 +437,16 @@ export default { this.customForm.dataKey ); }, + + initSortable() { + this.sortable = new Sortable(document.getElementById(`list-options-${this.customForm.dataKey}`), { + animation: 150, + handle: '.draggable-row', // The element that is active to drag + ghostClass: 'blue-background-class', + dragClass: 'white-opacity-background-class', + onEnd: this.updateOptionOrder, + }); + }, updateOptionValue(index, e) { this.form.options.value[index] = e.target.value; @@ -435,16 +461,6 @@ export default { this.updateStore(); }, - initSortable() { - this.sortable = new Sortable(document.getElementById(`list-options-${this.customForm.dataKey}`), { - animation: 150, - handle: '.draggable-row', // The element that is active to drag - ghostClass: 'blue-background-class', - dragClass: 'white-opacity-background-class', - onEnd: this.updateOptionOrder, - }); - }, - addOption() { this.form.options.value.push(''); }, @@ -453,22 +469,6 @@ export default { this.form.options.value.splice(index, 1); }, - updateStore() { - const data = { - dataKey: this.customForm.dataKey, - isMandatory: this.form.isFieldMandatory, - label: this.form.label.value, - name: this.form.name.value, - position: this.form.position.value, - field_type: this.form.field_type.value, - options: this.form.options.value, - }; - this.$store.commit('feature-type/UPDATE_CUSTOM_FORM', data); - if (this.customForm.name === this.selectedColorStyle ) { - this.$emit('update', this.form.options.value); - } - }, - trimWhiteSpace(string) { // TODO : supprimer les espaces pour chaque option au début et à la fin QUE à la validation return string.replace(/\s*,\s*/gi, ','); @@ -497,7 +497,7 @@ export default { } if (this.form.field_type.value === 'pre_recorded_list') { return this.form.options.value.length === 1 ? - '' : 'Veuillez renseigner une option.'; + '' : 'Veuillez sélectionner une option.'; } return ''; },