Commit fe81e7b7 authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Show errors close to the textarea

parent 0d78eeb2
...@@ -98,7 +98,11 @@ ...@@ -98,7 +98,11 @@
if (res.errors.commands_only) { if (res.errors.commands_only) {
this.discard(); this.discard();
} else { } else {
Flash('Something went wrong while adding your comment. Please try again.'); Flash(
'Something went wrong while adding your comment. Please try again.',
'alert',
$(this.$refs.commentForm),
);
} }
} else { } else {
this.discard(); this.discard();
...@@ -168,7 +172,7 @@ ...@@ -168,7 +172,7 @@
<ul <ul
v-if="isLoggedIn" v-if="isLoggedIn"
class="notes notes-form timeline new-note"> class="notes notes-form timeline new-note">
<li class="timeline-entry"> <li class="timeline-entry" ref="commentForm">
<div class="timeline-entry-inner"> <div class="timeline-entry-inner">
<div class="flash-container timeline-content"></div> <div class="flash-container timeline-content"></div>
<div class="timeline-icon hidden-xs hidden-sm"> <div class="timeline-icon hidden-xs hidden-sm">
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
}); });
} }
}, },
formUpdateHandler(noteText) { formUpdateHandler(noteText, parentElement) {
const data = { const data = {
endpoint: this.note.path, endpoint: this.note.path,
note: { note: {
...@@ -92,7 +92,11 @@ ...@@ -92,7 +92,11 @@
// TODO: this could be moved down, by setting a prop // TODO: this could be moved down, by setting a prop
$(this.$refs.noteBody.$el).renderGFM(); $(this.$refs.noteBody.$el).renderGFM();
}) })
.catch(() => Flash('Something went wrong while editing your comment. Please try again.')); .catch(() => Flash(
'Something went wrong while editing your comment. Please try again.',
'alert',
$(parentElement),
));
}, },
formCancelHandler(shouldConfirm, isDirty) { formCancelHandler(shouldConfirm, isDirty) {
if (shouldConfirm && isDirty) { if (shouldConfirm && isDirty) {
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
}); });
} }
}, },
handleFormUpdate(note) { handleFormUpdate(note, parentElement) {
this.$emit('handleFormUpdate', note); this.$emit('handleFormUpdate', note, parentElement);
}, },
formCancelHandler(shouldConfirm, isDirty) { formCancelHandler(shouldConfirm, isDirty) {
this.$emit('cancelFormEdition', shouldConfirm, isDirty); this.$emit('cancelFormEdition', shouldConfirm, isDirty);
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
methods: { methods: {
handleUpdate() { handleUpdate() {
this.isSubmitting = true; this.isSubmitting = true;
this.$emit('handleFormUpdate', this.note); this.$emit('handleFormUpdate', this.note, this.$refs.editNoteForm);
}, },
editMyLastNote() { editMyLastNote() {
if (this.note === '') { if (this.note === '') {
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
}, },
watch: { watch: {
noteBody() { noteBody() {
debugger;
if (this.note === this.initialNote) { if (this.note === this.initialNote) {
this.note = this.noteBody; this.note = this.noteBody;
} else { } else {
...@@ -105,7 +106,7 @@ ...@@ -105,7 +106,7 @@
</script> </script>
<template> <template>
<div class="note-edit-form current-note-edit-form"> <div ref="editNoteForm" class="note-edit-form current-note-edit-form">
<div <div
v-if="conflictWhileEditing" v-if="conflictWhileEditing"
class="js-conflict-edit-warning alert alert-danger"> class="js-conflict-edit-warning alert alert-danger">
...@@ -116,6 +117,7 @@ ...@@ -116,6 +117,7 @@
rel="noopener noreferrer">updated comment</a> rel="noopener noreferrer">updated comment</a>
to ensure information is not lost. to ensure information is not lost.
</div> </div>
<div class="flash-container timeline-content"></div>
<form <form
class="edit-note common-note-form"> class="edit-note common-note-form">
<markdown-field <markdown-field
......
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