mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #5244 from jaswilli/autosave-status
Do not allow auto-save to publish a post
This commit is contained in:
commit
52cce38137
1 changed files with 19 additions and 5 deletions
|
@ -35,12 +35,19 @@ EditorControllerMixin = Ember.Mixin.create({
|
|||
// Don't save just because we swapped out models
|
||||
if (this.get('model.isDraft') && !this.get('model.isNew')) {
|
||||
var autoSaveId,
|
||||
timedSaveId;
|
||||
timedSaveId,
|
||||
saveOptions;
|
||||
|
||||
timedSaveId = Ember.run.throttle(this, 'send', 'save', {silent: true, disableNProgress: true}, 60000, false);
|
||||
saveOptions = {
|
||||
silent: true,
|
||||
disableNProgress: true,
|
||||
backgroundSave: true
|
||||
};
|
||||
|
||||
timedSaveId = Ember.run.throttle(this, 'send', 'save', saveOptions, 60000, false);
|
||||
this.set('timedSaveId', timedSaveId);
|
||||
|
||||
autoSaveId = Ember.run.debounce(this, 'send', 'save', {silent: true, disableNProgress: true}, 3000);
|
||||
autoSaveId = Ember.run.debounce(this, 'send', 'save', saveOptions, 3000);
|
||||
this.set('autoSaveId', autoSaveId);
|
||||
}
|
||||
}.observes('model.scratch'),
|
||||
|
@ -228,7 +235,7 @@ EditorControllerMixin = Ember.Mixin.create({
|
|||
|
||||
actions: {
|
||||
save: function (options) {
|
||||
var status = this.get('willPublish') ? 'published' : 'draft',
|
||||
var status,
|
||||
prevStatus = this.get('model.status'),
|
||||
isNew = this.get('model.isNew'),
|
||||
autoSaveId = this.get('autoSaveId'),
|
||||
|
@ -239,6 +246,13 @@ EditorControllerMixin = Ember.Mixin.create({
|
|||
|
||||
options = options || {};
|
||||
|
||||
if (options.backgroundSave) {
|
||||
// do not allow a post's status to be set to published by a background save
|
||||
status = 'draft';
|
||||
} else {
|
||||
status = this.get('willPublish') ? 'published' : 'draft';
|
||||
}
|
||||
|
||||
if (autoSaveId) {
|
||||
Ember.run.cancel(autoSaveId);
|
||||
this.set('autoSaveId', null);
|
||||
|
@ -348,7 +362,7 @@ EditorControllerMixin = Ember.Mixin.create({
|
|||
|
||||
autoSaveNew: function () {
|
||||
if (this.get('model.isNew')) {
|
||||
this.send('save', {silent: true, disableNProgress: true});
|
||||
this.send('save', {silent: true, disableNProgress: true, backgroundSave: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue