Skip to content
Snippets Groups Projects
Commit 3c24cb88 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmine-issues/12012' into 'develop'

parents c86c47bc 23020bc5
No related branches found
No related tags found
No related merge requests found
...@@ -284,46 +284,37 @@ export default { ...@@ -284,46 +284,37 @@ export default {
}, },
checkUniqueName() { checkUniqueName() {
console.log(this.$store); const occurences = this.$store.state.feature_type.customForms
console.log(this.$store.state); .map((el) => el.name)
console.log(this.$store.state.feature_type); .filter((el) => el === this.form.name.value);
if (this.form.name.value) { return occurences.length === 1;
const occurences = this.$store.state.feature_type.customForms
.map((el) => el.name)
.filter((el) => el === this.form.name.value);
console.log("occurences", occurences);
console.log(occurences.length);
if (occurences.length > 1) {
console.log("duplicate", this.form.name.value);
this.form.name.errors = [
"Les champs personnalisés ne peuvent pas avoir des noms similaires.",
];
return false;
}
}
this.form.name.errors = [];
return true;
}, },
checkCustomForm() { checkCustomForm() {
if (this.form.label.value === null) { this.form.label.errors = [];
this.form.name.errors = [];
if (!this.form.label.value) {
//* vérifier que le label est renseigné
this.form.label.errors = ["Veuillez compléter ce champ."]; this.form.label.errors = ["Veuillez compléter ce champ."];
return false; return false;
} else if (this.form.name.value === null) { } else if (!this.form.name.value) {
//* vérifier que le nom est renseigné
this.form.name.errors = ["Veuillez compléter ce champ."]; this.form.name.errors = ["Veuillez compléter ce champ."];
this.form.label.errors = [];
return false; return false;
} else if (!this.hasRegularCharacters(this.form.name.value)) { } else if (!this.hasRegularCharacters(this.form.name.value)) {
//* vérifier qu'il n'y a pas de caractères spéciaux
this.form.name.errors = [ this.form.name.errors = [
"Veuillez utiliser seulement les caratères autorisés.", "Veuillez utiliser seulement les caratères autorisés.",
]; ];
this.form.label.errors = [];
return false; return false;
} else if (this.checkUniqueName()) { } else if (!this.checkUniqueName()) {
this.form.label.errors = []; //* vérifier si les noms sont pas dupliqués
this.form.name.errors = []; this.form.name.errors = [
return true; "Les champs personnalisés ne peuvent pas avoir des noms similaires.",
];
return false;
} }
return true;
}, },
}, },
......
...@@ -153,7 +153,6 @@ ...@@ -153,7 +153,6 @@
<i class="white save icon"></i> <i class="white save icon"></i>
Créer et importer le(s) signalement(s) du geojson Créer et importer le(s) signalement(s) du geojson
</button> </button>
</form> </form>
</div> </div>
</div> </div>
...@@ -345,13 +344,14 @@ export default { ...@@ -345,13 +344,14 @@ export default {
}, },
checkCustomForms() { checkCustomForms() {
let is_valid = true;
if (this.$refs.customForms) if (this.$refs.customForms)
for (const customForm of this.$refs.customForms) { for (const customForm of this.$refs.customForms) {
if (customForm.checkCustomForm() === false) { if (customForm.checkCustomForm() === false) {
return false; is_valid = false;
} }
} }
return true; //* fallback if all customForms returned true return is_valid; //* fallback if all customForms returned true
}, },
checkForms() { checkForms() {
......
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