diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index c4f5a51f64c842821514d29f8c64d4465c96ac44..b09eee67b90a93aa61afee4d7459c0219f8e7a94 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" @@ -383,7 +387,7 @@ export default { comment: { id_for_label: "add-comment", html_name: "add-comment", - errors: null, + errors: "", value: null, }, non_field_errors: [], @@ -466,8 +470,18 @@ export default { this.addFeatureToMap(); }, + validateForm() { + this.comment_form.comment.errors = "" + if (!this.comment_form.comment.value) { + this.comment_form.comment.errors = "Le commentaire ne peut pas être vide" + return false; + } + return true; + }, + postComment() { - featureAPI + if (this.validateForm()) { + featureAPI .postComment({ featureId: this.$route.params.slug_signal, comment: this.comment_form.comment.value, @@ -489,6 +503,7 @@ export default { this.confirmComment(); } }); + } }, confirmComment() {