mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Don't do autosave on new post
closes #5130 - rather than checking for a model change, noop autosave on new controller
This commit is contained in:
parent
7a5a9eed69
commit
8f354ddbc2
2 changed files with 3 additions and 18 deletions
|
@ -2,6 +2,8 @@ import Ember from 'ember';
|
||||||
import EditorControllerMixin from 'ghost/mixins/editor-base-controller';
|
import EditorControllerMixin from 'ghost/mixins/editor-base-controller';
|
||||||
|
|
||||||
var EditorNewController = Ember.Controller.extend(EditorControllerMixin, {
|
var EditorNewController = Ember.Controller.extend(EditorControllerMixin, {
|
||||||
|
// Overriding autoSave on the base controller, as the new controller shouldn't be autosaving
|
||||||
|
autoSave: Ember.K,
|
||||||
actions: {
|
actions: {
|
||||||
/**
|
/**
|
||||||
* Redirect to editor after the first save
|
* Redirect to editor after the first save
|
||||||
|
|
|
@ -31,26 +31,9 @@ EditorControllerMixin = Ember.Mixin.create({
|
||||||
return self.get('isDirty') ? self.unloadDirtyMessage() : null;
|
return self.get('isDirty') ? self.unloadDirtyMessage() : null;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
lastModelId: null,
|
|
||||||
modelChanged: Ember.computed('model.id', function (key, value) {
|
|
||||||
var modelId = this.get('model.id');
|
|
||||||
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.get('lastModelId') === modelId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set('lastModelId', modelId);
|
|
||||||
return true;
|
|
||||||
}),
|
|
||||||
autoSave: function () {
|
autoSave: function () {
|
||||||
// Don't save just because we swapped out models
|
// Don't save just because we swapped out models
|
||||||
if (this.get('modelChanged')) {
|
if (this.get('model.isDraft') && !this.get('model.isNew')) {
|
||||||
this.set('modelChanged', false);
|
|
||||||
} else if (this.get('model.isDraft') && !this.get('model.isNew')) {
|
|
||||||
var autoSaveId,
|
var autoSaveId,
|
||||||
timedSaveId;
|
timedSaveId;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue