# HG changeset patch # User Alexandre Segura # Date 1490009166 -3600 # Node ID 8602c254b9eb9bfb218e8893db2e461dd00239fb # Parent 04ac84f80eb396d24301eee48e6b80544ef42a6a Validate form with at least one tag, improve validation. diff -r 04ac84f80eb3 -r 8602c254b9eb src_js/iconolab-bundle/src/components/editor/Tooltip.vue --- a/src_js/iconolab-bundle/src/components/editor/Tooltip.vue Fri Mar 17 18:17:07 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/Tooltip.vue Mon Mar 20 12:26:06 2017 +0100 @@ -4,17 +4,19 @@ -
+
- + + Vous devez spécifier un titre
-
+
- + + Vous devez spécifier au moins un mot-clé
@@ -39,13 +41,19 @@ title: '', description: '', tags: [], - error: false + titleError: false, + tagsError: false } }, computed: { - titleFormGroup: function() { + titleFormGroupClass: function() { return { - 'has-error': this.error + 'has-error': this.titleError + } + }, + tagsFormGroupClass: function() { + return { + 'has-error': this.tagsError } } }, @@ -56,11 +64,6 @@ if (this.originalDescription) { this.description = this.originalDescription; } - this.$on('error', (err) => { - if (err.title) { - this.error = true; - } - }); }, methods: { close: function(e) { @@ -70,11 +73,17 @@ save: function(e) { e.preventDefault(); - this.error = false; + Object.assign(this, { + titleError: false, + tagsError: false, + }); if (this.title.trim().length === 0) { - this.$emit('error', { - title: true - }); + this.titleError = true; + } + if (this.$refs.taglist.tags.length === 0) { + this.tagsError = true; + } + if (this.titleError || this.tagsError) { return; }