diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index 9a8b3e83a9bc8c6a63b76c810a75bf08e48ed5cb..9098d81ff02c3bffb02c341b9ac72a63b55ba673 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -251,7 +251,11 @@ <label :for="comment_form.comment.id_for_label" >Ajouter un commentaire</label > - {{ comment_form.comment.errors }} + <ul v-if="comment_form.comment.errors" class="errorlist"> + <li> + {{ comment_form.comment.errors }} + </li> + </ul> <textarea v-model="comment_form.comment.value" :name="comment_form.comment.html_name" @@ -384,7 +388,7 @@ export default { comment: { id_for_label: "add-comment", html_name: "add-comment", - errors: null, + errors: "", value: null, }, non_field_errors: [], @@ -467,8 +471,18 @@ export default { this.addFeatureToMap(); }, + validateForm() { + this.comment_form.comment.errors = "" + if (!this.comment_form.comment.value) { + this.comment_form.comment.errors = "Ce champ est obligatoire." + return false; + } + return true; + }, + postComment() { - featureAPI + if (this.validateForm()) { + featureAPI .postComment({ featureId: this.$route.params.slug_signal, comment: this.comment_form.comment.value, @@ -490,6 +504,7 @@ export default { this.confirmComment(); } }); + } }, confirmComment() {