Skip to content
Snippets Groups Projects
Commit c9eaa0fb authored by Timothee P's avatar Timothee P :sunflower:
Browse files

validate form on comment post

parent ca942547
No related branches found
No related tags found
2 merge requests!2132.3.2-rc1,!200REDMINE_ISSUES-12030
......@@ -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() {
......
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