summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes
diff options
context:
space:
mode:
authorAndré Luís <aluis@gitlab.com>2018-07-31 01:51:06 +0100
committerAndré Luís <aluis@gitlab.com>2018-08-01 13:45:15 +0100
commitc7cd9ee97cfe1ca8c997b3aad03eb40f5002b317 (patch)
tree4f1b61fcc80f2c76b1428be9e4349fbc5c9a9680 /app/assets/javascripts/notes
parent8693aa139dcdc5d4ed8939d12b360731f5f9dab8 (diff)
downloadgitlab-ce-c7cd9ee97cfe1ca8c997b3aad03eb40f5002b317.tar.gz
Revert "Merge branch '_acet-fix-mr-autosave' into 'master'"
This reverts commit 5ba542b1094bd8fd95d48d2ac834fd8605cf8fee, reversing changes made to 32c831ea2b8425c71c790b67fb8f2170f3d9955a.
Diffstat (limited to 'app/assets/javascripts/notes')
-rw-r--r--app/assets/javascripts/notes/components/note_form.vue2
-rw-r--r--app/assets/javascripts/notes/components/noteable_discussion.vue34
-rw-r--r--app/assets/javascripts/notes/mixins/autosave.js17
3 files changed, 21 insertions, 32 deletions
diff --git a/app/assets/javascripts/notes/components/note_form.vue b/app/assets/javascripts/notes/components/note_form.vue
index abcd4422d7c..26482a02e00 100644
--- a/app/assets/javascripts/notes/components/note_form.vue
+++ b/app/assets/javascripts/notes/components/note_form.vue
@@ -7,7 +7,7 @@ import issuableStateMixin from '../mixins/issuable_state';
import resolvable from '../mixins/resolvable';
export default {
- name: 'NoteForm',
+ name: 'IssueNoteForm',
components: {
issueWarning,
markdownField,
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue
index 2f1a68731c7..bee635398b3 100644
--- a/app/assets/javascripts/notes/components/noteable_discussion.vue
+++ b/app/assets/javascripts/notes/components/noteable_discussion.vue
@@ -6,7 +6,6 @@ import nextDiscussionsSvg from 'icons/_next_discussion.svg';
import { convertObjectPropsToCamelCase, scrollToElement } from '~/lib/utils/common_utils';
import { truncateSha } from '~/lib/utils/text_utility';
import systemNote from '~/vue_shared/components/notes/system_note.vue';
-import { s__ } from '~/locale';
import Flash from '../../flash';
import { SYSTEM_NOTE } from '../constants';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
@@ -145,17 +144,19 @@ export default {
return this.isDiffDiscussion ? '' : 'card discussion-wrapper';
},
},
- watch: {
- isReplying() {
- if (this.isReplying) {
- this.$nextTick(() => {
- // Pass an extra key to separate reply and note edit forms
- this.initAutoSave(this.transformedDiscussion, ['Reply']);
- });
+ mounted() {
+ if (this.isReplying) {
+ this.initAutoSave(this.transformedDiscussion);
+ }
+ },
+ updated() {
+ if (this.isReplying) {
+ if (!this.autosave) {
+ this.initAutoSave(this.transformedDiscussion);
} else {
- this.disposeAutoSave();
+ this.setAutoSave();
}
- },
+ }
},
created() {
this.resolveDiscussionsSvg = resolveDiscussionsSvg;
@@ -193,18 +194,16 @@ export default {
showReplyForm() {
this.isReplying = true;
},
- cancelReplyForm(shouldConfirm, isDirty) {
- if (shouldConfirm && isDirty) {
- const msg = s__('Notes|Are you sure you want to cancel creating this comment?');
-
+ cancelReplyForm(shouldConfirm) {
+ if (shouldConfirm && this.$refs.noteForm.isDirty) {
// eslint-disable-next-line no-alert
- if (!window.confirm(msg)) {
+ if (!window.confirm('Are you sure you want to cancel creating this comment?')) {
return;
}
}
- this.isReplying = false;
this.resetAutoSave();
+ this.isReplying = false;
},
saveReply(noteText, form, callback) {
const postData = {
@@ -421,8 +420,7 @@ Please check your network connection and try again.`;
:is-editing="false"
save-button-title="Comment"
@handleFormUpdate="saveReply"
- @cancelForm="cancelReplyForm"
- />
+ @cancelForm="cancelReplyForm" />
<note-signed-out-widget v-if="!canReply" />
</div>
</div>
diff --git a/app/assets/javascripts/notes/mixins/autosave.js b/app/assets/javascripts/notes/mixins/autosave.js
index 4f45f912479..36cc8d5d056 100644
--- a/app/assets/javascripts/notes/mixins/autosave.js
+++ b/app/assets/javascripts/notes/mixins/autosave.js
@@ -4,18 +4,12 @@ import { capitalizeFirstCharacter } from '../../lib/utils/text_utility';
export default {
methods: {
- initAutoSave(noteable, extraKeys = []) {
- let keys = [
+ initAutoSave(noteable) {
+ this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), [
'Note',
- capitalizeFirstCharacter(noteable.noteable_type || noteable.noteableType),
+ capitalizeFirstCharacter(noteable.noteable_type),
noteable.id,
- ];
-
- if (extraKeys) {
- keys = keys.concat(extraKeys);
- }
-
- this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), keys);
+ ]);
},
resetAutoSave() {
this.autosave.reset();
@@ -23,8 +17,5 @@ export default {
setAutoSave() {
this.autosave.save();
},
- disposeAutoSave() {
- this.autosave.dispose();
- },
},
};