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

display more informative message on option field

parent 4ec40331
No related branches found
No related tags found
1 merge request!587REDMINE_ISSUE-17413 | Nouveau formulaire de création des listes de valeurs
......@@ -490,20 +490,23 @@ export default {
return occurences.length === 1;
},
checkListOptions() {
if (!['list', 'pre_recorded_list'].includes(this.form.field_type.value)) return true;
checkOptions() {
if (this.form.field_type.value === 'list') {
return this.form.options.value.length >= 2 && !this.form.options.value.includes('');
return this.form.options.value.length >= 2 && !this.form.options.value.includes('') ?
'' : 'Veuillez renseigner au moins 2 options.';
}
if (this.form.field_type.value === 'pre_recorded_list') {
return this.form.options.value.length === 1;
return this.form.options.value.length === 1 ?
'' : 'Veuillez renseigner une option.';
}
return '';
},
checkCustomForm() {
this.form.label.errors = [];
this.form.name.errors = [];
this.form.options.errors = [];
const optionError = this.checkOptions();
let isValid = true;
if (!this.form.label.value) {
//* vérifier que le label est renseigné
......@@ -525,9 +528,9 @@ export default {
'Les champs personnalisés ne peuvent pas avoir des noms similaires.',
];
isValid = false;
} else if (!this.checkListOptions()) {
} else if (optionError) {
//* s'il s'agit d'un type liste, vérifier que le champ option est bien renseigné
this.form.options.errors = ['Veuillez compléter ce champ.'];
this.form.options.errors = [optionError];
isValid = false;
} else if (this.hasDuplicateOptions()) {
//* pour le cas d'options dupliqués
......
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