diff --git a/src/components/feature_type/FeatureTypeCustomForm.vue b/src/components/feature_type/FeatureTypeCustomForm.vue index 140a62b0765e06417bb45fb7e03a1283aebac863..83ac53b0dbfd5732968ce09ece09d991449c544c 100644 --- a/src/components/feature_type/FeatureTypeCustomForm.vue +++ b/src/components/feature_type/FeatureTypeCustomForm.vue @@ -249,12 +249,14 @@ export default { } this.updateStore(); }, + removeCustomForm() { this.$store.commit( "feature_type/REMOVE_CUSTOM_FORM", this.customForm.dataKey ); }, + updateStore() { const data = { dataKey: this.customForm.dataKey, @@ -266,10 +268,21 @@ export default { }; this.$store.commit("feature_type/UPDATE_CUSTOM_FORM", data); }, + trimWhiteSpace(string) { // TODO : supprimer les espaces pour chaque option au début et à la fin QUE à la validation return string.replace(/\s*,\s*/gi, ","); }, + + hasRegularCharacters(input) { + for (let char of input) { + if (!/[a-zA-Z0-9-_]/.test(char)) { + return false; + } + } + return true; + }, + checkCustomForm() { if (this.form.label.value === null) { this.form.label.errors = ["Veuillez compléter ce champ."]; @@ -278,6 +291,12 @@ export default { this.form.name.errors = ["Veuillez compléter ce champ."]; this.form.label.errors = []; return false; + } else if (!this.hasRegularCharacters(this.form.name.value)) { + this.form.name.errors = [ + "Veuillez utiliser seulement les caratères autorisés.", + ]; + this.form.label.errors = []; + return false; } this.form.label.errors = []; this.form.name.errors = []; diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 9ba25f8a47dd2a05bc3a54a3505aab30d49581e0..69b931dd72496527d5b20f6d97f9f18e8732668d 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -154,7 +154,6 @@ Créer et importer le(s) signalement(s) du geojson </button> - <!-- // TODO: Add check script for form & other scripts // --> </form> </div> </div>