diff --git a/ghost/admin/controllers/posts/post.js b/ghost/admin/controllers/posts/post.js
index ac10e1fa5e..9070748c65 100644
--- a/ghost/admin/controllers/posts/post.js
+++ b/ghost/admin/controllers/posts/post.js
@@ -1,12 +1,17 @@
+/* global console */
import {parseDateString, formatDate} from 'ghost/utils/date-formatting';
var equal = Ember.computed.equal;
var PostController = Ember.ObjectController.extend({
+ //## Editor state properties
+ isEditingSettings: false,
+ isViewingSaveTypes: false,
+ //## Computed post properties
isPublished: equal('status', 'published'),
isDraft: equal('status', 'draft'),
- isEditingSettings: false,
+ willPublish: Ember.computed.oneWay('isPublished'),
isStaticPage: function (key, val) {
if (arguments.length > 1) {
this.set('model.page', val ? 1 : 0);
@@ -51,11 +56,31 @@ var PostController = Ember.ObjectController.extend({
publishedAtChanged: function () {
this.set('publishedAt', formatDate(this.get('model.published_at')));
}.observes('model.published_at'),
-
+
actions: {
+ save: function () {
+ var status = this.get('willPublish') ? 'published' : 'draft',
+ self = this;
+ this.set('model.status', status);
+ this.get('model').save().then(function () {
+ self.notifications.showSuccess('Post status saved as ' + this.get('model.status') + '.');
+ }, this.notifications.showErrors);
+ },
+ viewSaveTypes: function () {
+ this.toggleProperty('isViewingSaveTypes');
+ },
+ setSaveType: function (newType) {
+ if (newType === 'publish') {
+ this.set('willPublish', true);
+ } else if (newType === 'draft') {
+ this.set('willPublish', false);
+ } else {
+ console.warn('Received invalid save type; ignoring.');
+ }
+ },
editSettings: function () {
- this.toggleProperty('isEditingSettings');
- if (this.get('isEditingSettings')) {
+ var isEditing = this.toggleProperty('isEditingSettings');
+ if (isEditing) {
//Stop editing if the user clicks outside the settings view
Ember.run.next(this, function () {
var self = this;
@@ -71,9 +96,9 @@ var PostController = Ember.ObjectController.extend({
slug = this.get('model.slug'),
placeholder = this.get('slugPlaceholder'),
self = this;
-
+
newSlug = (!newSlug && placeholder) ? placeholder : newSlug;
-
+
// Ignore unchanged slugs
if (slug === newSlug) {
return;
@@ -93,7 +118,7 @@ var PostController = Ember.ObjectController.extend({
if (!this.get('isOnServer')) {
return;
}
-
+
this.get('model').save('slug').then(function () {
self.notifications.showSuccess('Permalink successfully changed to ' + this.get('model.slug') + '.');
}, this.notifications.showErrors);
@@ -165,7 +190,7 @@ var PostController = Ember.ObjectController.extend({
if (!this.get('isOnServer')) {
return;
}
-
+
this.get('model').save('published_at').then(function () {
this.notifications.showSuccess('Publish date successfully changed to ' + this.get('publishedAt') + '.');
}, this.notifications.showErrors);
@@ -173,4 +198,4 @@ var PostController = Ember.ObjectController.extend({
}
});
-export default PostController;
+export default PostController;
\ No newline at end of file
diff --git a/ghost/admin/routes/new.js b/ghost/admin/routes/new.js
index eaebfd91af..ea320e8fec 100644
--- a/ghost/admin/routes/new.js
+++ b/ghost/admin/routes/new.js
@@ -1,12 +1,18 @@
-import styleBody from 'ghost/mixins/style-body';
import AuthenticatedRoute from 'ghost/routes/authenticated';
+import styleBody from 'ghost/mixins/style-body';
+import Post from 'ghost/models/post';
var NewRoute = AuthenticatedRoute.extend(styleBody, {
+ controllerName: 'posts/post',
classNames: ['editor'],
renderTemplate: function () {
this.render('editor');
+ },
+
+ model: function () {
+ return Post.create();
}
});
-export default NewRoute;
\ No newline at end of file
+export default NewRoute;
diff --git a/ghost/admin/templates/-publish-bar.hbs b/ghost/admin/templates/-publish-bar.hbs
index 77f77a48a1..8a79a404a5 100644
--- a/ghost/admin/templates/-publish-bar.hbs
+++ b/ghost/admin/templates/-publish-bar.hbs
@@ -15,15 +15,7 @@
{{view "post-settings-menu-view"}}
-