Cancel pending auto-save if manual save occurs

Closes #4309
This commit is contained in:
Jason Williams 2014-10-20 18:03:11 +00:00
parent 58d11de2dd
commit 58fda8a9a4
3 changed files with 16 additions and 6 deletions

View File

@ -21,8 +21,7 @@ var onChangeHandler = function (cm, changeObj) {
cm.component.set('value', cm.getValue());
// Send an action notifying a 5 second pause in typing/changes.
Ember.run.debounce(component, 'sendAction', 'typingPause', 3000);
component.sendAction('typingPause');
};
var onScrollHandler = function (cm) {

View File

@ -194,9 +194,16 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
var status = this.get('willPublish') ? 'published' : 'draft',
prevStatus = this.get('status'),
isNew = this.get('isNew'),
autoSaveId = this.get('autoSaveId'),
self = this;
options = options || {};
if(autoSaveId) {
Ember.run.cancel(autoSaveId);
this.set('autoSaveId', null);
}
self.notifications.closePassive();
// ensure an incomplete tag is finalised before save
@ -296,13 +303,17 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
autoSave: function () {
if (this.get('model.isDraft')) {
this.send('save', {silent: true, disableNProgress: true});
var autoSaveId;
autoSaveId = Ember.run.debounce(this, 'send', 'save', {silent: true, disableNProgress: true}, 3000);
this.set('autoSaveId', autoSaveId);
}
},
autoSaveNew: function () {
if (this.get('isNew')) {
this.send('autoSave');
this.send('save', {silent: true, disableNProgress: true});
}
}
}

View File

@ -247,7 +247,7 @@ casper.on('remote.message', function (msg) {
// output any errors
casper.on('error', function (msg, trace) {
casper.echoConcise('ERROR, ' + msg, 'ERROR');
if (trace) {
if (trace && trace[0]) {
casper.echoConcise('file: ' + trace[0].file, 'WARNING');
casper.echoConcise('line: ' + trace[0].line, 'WARNING');
casper.echoConcise('function: ' + trace[0]['function'], 'WARNING');
@ -258,7 +258,7 @@ casper.on('error', function (msg, trace) {
// output any page errors
casper.on('page.error', function (msg, trace) {
casper.echoConcise('PAGE ERROR: ' + msg, 'ERROR');
if (trace) {
if (trace && trace[0]) {
casper.echoConcise('file: ' + trace[0].file, 'WARNING');
casper.echoConcise('line: ' + trace[0].line, 'WARNING');
casper.echoConcise('function: ' + trace[0]['function'], 'WARNING');