提交 85f2d7d4 编写于 作者: F Filipa Lacerda

[ci skip] Disable submit button when submitting a note or if the note is empty...

[ci skip] Disable submit button when submitting a note or if the note is empty while editing or adding a reply to a discussion
上级 23b83d5f
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
initialNote: this.noteBody, initialNote: this.noteBody,
note: this.noteBody, note: this.noteBody,
conflictWhileEditing: false, conflictWhileEditing: false,
isSubmitting: false,
}; };
}, },
components: { components: {
...@@ -59,10 +60,14 @@ ...@@ -59,10 +60,14 @@
}, },
currentUserId() { currentUserId() {
return this.getUserDataByProp('id'); return this.getUserDataByProp('id');
} },
isDisabled() {
return !this.note.length || this.isSubmitting;
},
}, },
methods: { methods: {
handleUpdate() { handleUpdate() {
this.isSubmitting = true;
this.$emit('handleFormUpdate', this.note); this.$emit('handleFormUpdate', this.note);
}, },
editMyLastNote() { editMyLastNote() {
...@@ -79,7 +84,7 @@ ...@@ -79,7 +84,7 @@
cancelHandler(shouldConfirm = false) { cancelHandler(shouldConfirm = false) {
// Sends information about confirm message and if the textarea has changed // Sends information about confirm message and if the textarea has changed
this.$emit('cancelFormEdition', shouldConfirm, this.initialNote !== this.note); this.$emit('cancelFormEdition', shouldConfirm, this.initialNote !== this.note);
} },
}, },
mounted() { mounted() {
this.$refs.textarea.focus(); this.$refs.textarea.focus();
...@@ -133,7 +138,8 @@ ...@@ -133,7 +138,8 @@
<div class="note-form-actions clearfix"> <div class="note-form-actions clearfix">
<button <button
type="button" type="button"
@click="handleUpdate" @click="handleUpdate"
:disabled="isDisabled"
class="btn btn-nr btn-save"> class="btn btn-nr btn-save">
{{saveButtonTitle}} {{saveButtonTitle}}
</button> </button>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册