From ebf7d52d7c994aab7c9890587a23f0fe7a049611 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Wed, 23 Aug 2017 15:40:52 +0300 Subject: IssueNotesRefactor: Hide note reply form when submitted and show it again if there is an error. --- .../notes/components/issue_discussion.vue | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'app/assets/javascripts/notes') diff --git a/app/assets/javascripts/notes/components/issue_discussion.vue b/app/assets/javascripts/notes/components/issue_discussion.vue index 6fdc85e52e3..b131ef4b182 100644 --- a/app/assets/javascripts/notes/components/issue_discussion.vue +++ b/app/assets/javascripts/notes/components/issue_discussion.vue @@ -110,7 +110,7 @@ this.resetAutoSave(); this.isReplying = false; }, - saveReply(noteText) { + saveReply(noteText, form, callback) { const replyData = { endpoint: this.newNotePath, flashContainer: this.$el, @@ -121,20 +121,22 @@ note: { note: noteText }, }, }; + this.isReplying = false; this.saveNote(replyData) .then(() => { - this.isReplying = false; this.resetAutoSave(); + callback(); }) - .catch(() => { - Flash( - 'Your comment could not be submitted! Please check your network connection and try again.', - 'alert', - $(this.$el), - ); + .catch((err) => { this.removePlaceholderNotes(); - this.$refs.noteForm.isSubmitting = false; + this.isReplying = true; + this.$nextTick(() => { + const msg = 'Your comment could not be submitted! Please check your network connection and try again.'; + Flash(msg, 'alert', $(this.$el)); + this.$refs.noteForm.note = noteText; + callback(err); + }); }); }, }, -- cgit v1.2.3