Commit fdfab012 authored by Filipa Lacerda's avatar Filipa Lacerda

Fixes autosave not enabling comment button when it is restored.

Adds back missing CSS class that was breaking tests
parent c9ac28fa
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
import AccessorUtilities from './lib/utils/accessor'; import AccessorUtilities from './lib/utils/accessor';
window.Autosave = (function() { window.Autosave = (function() {
function Autosave(field, key) { function Autosave(field, key, resource) {
this.field = field; this.field = field;
this.isLocalStorageAvailable = AccessorUtilities.isLocalStorageAccessSafe(); this.isLocalStorageAvailable = AccessorUtilities.isLocalStorageAccessSafe();
this.resource = resource;
if (key.join != null) { if (key.join != null) {
key = key.join("/"); key = key.join('/');
} }
this.key = "autosave/" + key; this.key = 'autosave/' + key;
this.field.data("autosave", this); this.field.data('autosave', this);
this.restore(); this.restore();
this.field.on("input", (function(_this) { this.field.on('input', (function(_this) {
return function() { return function() {
return _this.save(); return _this.save();
}; };
...@@ -29,7 +29,14 @@ window.Autosave = (function() { ...@@ -29,7 +29,14 @@ window.Autosave = (function() {
if ((text != null ? text.length : void 0) > 0) { if ((text != null ? text.length : void 0) > 0) {
this.field.val(text); this.field.val(text);
} }
return this.field.trigger("input"); if (!this.resource && this.resource !== 'issue') {
this.field.trigger('input');
} else {
// v-model does not update with jQuery trigger
// https://github.com/vuejs/vue/issues/2804#issuecomment-216968137
const event = new Event('change', { bubbles: true, cancelable: false });
this.field.get(0).dispatchEvent(event);
}
}; };
Autosave.prototype.save = function() { Autosave.prototype.save = function() {
......
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
} }
}, },
initAutoSave() { initAutoSave() {
this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getIssueData.id]); this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getIssueData.id], 'issue');
}, },
initTaskList() { initTaskList() {
return new TaskList({ return new TaskList({
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
<issue-note-signed-out-widget v-if="!isLoggedIn" /> <issue-note-signed-out-widget v-if="!isLoggedIn" />
<ul <ul
v-else v-else
class="notes notes-form timeline new-note"> class="notes notes-form timeline">
<li class="timeline-entry"> <li class="timeline-entry">
<div class="timeline-entry-inner"> <div class="timeline-entry-inner">
<div class="timeline-icon hidden-xs hidden-sm"> <div class="timeline-icon hidden-xs hidden-sm">
...@@ -223,10 +223,10 @@ ...@@ -223,10 +223,10 @@
:img-size="40" :img-size="40"
/> />
</div> </div>
<div > <div class="timeline-content timeline-content-form">
<form <form
ref="commentForm" ref="commentForm"
class="js-main-target-form timeline-content timeline-content-form common-note-form"> class="new-note js-quick-submit common-note-form gfm-form js-main-target-form">
<div class="flash-container timeline-content"></div> <div class="flash-container timeline-content"></div>
<confidentialIssue v-if="isConfidentialIssue" /> <confidentialIssue v-if="isConfidentialIssue" />
<markdown-field <markdown-field
......
...@@ -4,7 +4,7 @@ import '../../autosave'; ...@@ -4,7 +4,7 @@ import '../../autosave';
export default { export default {
methods: { methods: {
initAutoSave() { initAutoSave() {
this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), ['Note', 'Issue', this.note.id]); this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), ['Note', 'Issue', this.note.id], 'issue');
}, },
resetAutoSave() { resetAutoSave() {
this.autosave.reset(); this.autosave.reset();
......
...@@ -19,7 +19,7 @@ export const notesById = state => state.notes.reduce((acc, note) => { ...@@ -19,7 +19,7 @@ export const notesById = state => state.notes.reduce((acc, note) => {
const reverseNotes = array => array.slice(0).reverse(); const reverseNotes = array => array.slice(0).reverse();
const isLastNote = (note, state) => !note.system && const isLastNote = (note, state) => !note.system &&
state.userData && state.userData !== undefined &&
note.author.id === state.userData.id; note.author.id === state.userData.id;
export const getCurrentUserLastNote = state => _.flatten( export const getCurrentUserLastNote = state => _.flatten(
......
...@@ -20,10 +20,6 @@ ...@@ -20,10 +20,6 @@
} }
} }
.new-note {
display: none;
}
.new-note, .new-note,
.note-edit-form { .note-edit-form {
.note-form-actions { .note-form-actions {
......
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