Commit 2f53a8d0 authored by Phil Hughes's avatar Phil Hughes

Shows error if response returns an error

Added validation so the user shouldnt be able to submit the form without the title present
parent a68f1fdd
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
}, },
data() { data() {
return { return {
title: '' title: '',
error: false
}; };
}, },
watch: { watch: {
...@@ -19,6 +20,10 @@ ...@@ -19,6 +20,10 @@
methods: { methods: {
submit(e) { submit(e) {
e.preventDefault(); e.preventDefault();
if (this.title.trim() === '') return;
this.error = false;
const labels = this.list.label ? [this.list.label] : []; const labels = this.list.label ? [this.list.label] : [];
const issue = new ListIssue({ const issue = new ListIssue({
title: this.title, title: this.title,
...@@ -26,9 +31,21 @@ ...@@ -26,9 +31,21 @@
}); });
this.list.newIssue(issue) this.list.newIssue(issue)
.then(() => { .then((data) => {
// Need this because our jQuery very kindly disables buttons on ALL form submissions
$(this.$els.submitButton).enable();
})
.catch(() => {
// Need this because our jQuery very kindly disables buttons on ALL form submissions // Need this because our jQuery very kindly disables buttons on ALL form submissions
$(this.$els.submitButton).enable(); $(this.$els.submitButton).enable();
// Remove issue with no ID
const issue = this.list.findIssue(undefined);
this.list.removeIssue(issue);
// Show error message
this.error = true;
this.showIssueForm = true;
}); });
this.cancel(); this.cancel();
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
"v-show" => "list.type !== 'done' && showIssueForm" } "v-show" => "list.type !== 'done' && showIssueForm" }
.card.board-new-issue-form .card.board-new-issue-form
%form{ "@submit" => "submit($event)" } %form{ "@submit" => "submit($event)" }
.flash-container{ "v-if" => "error" }
.flash-alert
An error occured. Please try again.
%label.label-light{ ":for" => "list.id + '-title'" } %label.label-light{ ":for" => "list.id + '-title'" }
Title Title
%input.form-control{ type: "text", %input.form-control{ type: "text",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment