Commit 3158fa7e authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Improve code as per code reviews

parent c4381067
...@@ -29,18 +29,10 @@ ...@@ -29,18 +29,10 @@
}, },
watch: { watch: {
note(newNote) { note(newNote) {
if (!_.isEmpty(newNote) && !this.isSubmitting) { this.setIsSubmitButtonDisabled(newNote, this.isSubmitting);
this.isSubmitButtonDisabled = false;
} else {
this.isSubmitButtonDisabled = true;
}
}, },
isSubmitting(newValue) { isSubmitting(newValue) {
if (!_.isEmpty(this.note) && !newValue) { this.setIsSubmitButtonDisabled(this.note, newValue);
this.isSubmitButtonDisabled = false;
} else {
this.isSubmitButtonDisabled = true;
}
}, },
}, },
computed: { computed: {
...@@ -99,6 +91,13 @@ ...@@ -99,6 +91,13 @@
...mapActions([ ...mapActions([
'saveNote', 'saveNote',
]), ]),
setIsSubmitButtonDisabled(note, isSubmitting) {
if (!_.isEmpty(note) && !isSubmitting) {
this.isSubmitButtonDisabled = false;
} else {
this.isSubmitButtonDisabled = true;
}
},
handleSave(withIssueAction) { handleSave(withIssueAction) {
if (this.note.length) { if (this.note.length) {
const noteData = { const noteData = {
...@@ -176,7 +175,7 @@ ...@@ -176,7 +175,7 @@
}, },
editCurrentUserLastNote() { editCurrentUserLastNote() {
if (this.note === '') { if (this.note === '') {
const lastNote = this.getCurrentUserLastNote(window.gon.current_user_id); const lastNote = this.getCurrentUserLastNote;
if (lastNote) { if (lastNote) {
eventHub.$emit('enterEditMode', { eventHub.$emit('enterEditMode', {
......
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
title="Add a reply">Reply...</button> title="Add a reply">Reply...</button>
<issue-note-form <issue-note-form
v-if="isReplying" v-if="isReplying"
saveButtonTitle="Comment" save-button-title="Comment"
:discussion="note" :discussion="note"
:is-editing="false" :is-editing="false"
@handleFormUpdate="saveReply" @handleFormUpdate="saveReply"
......
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