提交 fdfab012 编写于 作者: F Filipa Lacerda

Fixes autosave not enabling comment button when it is restored.

Adds back missing CSS class that was breaking tests
上级 c9ac28fa
......@@ -2,17 +2,17 @@
import AccessorUtilities from './lib/utils/accessor';
window.Autosave = (function() {
function Autosave(field, key) {
function Autosave(field, key, resource) {
this.field = field;
this.isLocalStorageAvailable = AccessorUtilities.isLocalStorageAccessSafe();
this.resource = resource;
if (key.join != null) {
key = key.join("/");
key = key.join('/');
}
this.key = "autosave/" + key;
this.field.data("autosave", this);
this.key = 'autosave/' + key;
this.field.data('autosave', this);
this.restore();
this.field.on("input", (function(_this) {
this.field.on('input', (function(_this) {
return function() {
return _this.save();
};
......@@ -29,7 +29,14 @@ window.Autosave = (function() {
if ((text != null ? text.length : void 0) > 0) {
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() {
......
......@@ -184,7 +184,7 @@
}
},
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() {
return new TaskList({
......@@ -211,7 +211,7 @@
<issue-note-signed-out-widget v-if="!isLoggedIn" />
<ul
v-else
class="notes notes-form timeline new-note">
class="notes notes-form timeline">
<li class="timeline-entry">
<div class="timeline-entry-inner">
<div class="timeline-icon hidden-xs hidden-sm">
......@@ -223,10 +223,10 @@
:img-size="40"
/>
</div>
<div >
<div class="timeline-content timeline-content-form">
<form
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>
<confidentialIssue v-if="isConfidentialIssue" />
<markdown-field
......
......@@ -4,7 +4,7 @@ import '../../autosave';
export default {
methods: {
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() {
this.autosave.reset();
......
......@@ -19,7 +19,7 @@ export const notesById = state => state.notes.reduce((acc, note) => {
const reverseNotes = array => array.slice(0).reverse();
const isLastNote = (note, state) => !note.system &&
state.userData &&
state.userData !== undefined &&
note.author.id === state.userData.id;
export const getCurrentUserLastNote = state => _.flatten(
......
......@@ -20,10 +20,6 @@
}
}
.new-note {
display: none;
}
.new-note,
.note-edit-form {
.note-form-actions {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册