From a7daeecbf2eee72e786f3733c643516c9cac25b0 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 16 Jun 2014 05:44:07 +0000 Subject: [PATCH 1/2] Content screen: Featured posts fixes #2748 - Properly handle marking post as featured/non-featured - Show correct notifications --- ghost/admin/controllers/posts/post.js | 12 ++++++++++-- ghost/admin/views/post-item-view.js | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ghost/admin/controllers/posts/post.js b/ghost/admin/controllers/posts/post.js index 82ede268f7..7bab3eea7a 100644 --- a/ghost/admin/controllers/posts/post.js +++ b/ghost/admin/controllers/posts/post.js @@ -1,11 +1,19 @@ var PostController = Ember.ObjectController.extend({ isPublished: Ember.computed.equal('status', 'published'), + classNameBindings: ['featured'], actions: { toggleFeatured: function () { - this.set('featured', !this.get('featured')); + var featured = !this.get('featured'), + self = this; - this.get('model').save(); + this.set('featured', featured); + + this.get('model').save().then(function () { + self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.'); + }, function() { + self.notifications.showError('An error occured while saving the post.'); + }); } } }); diff --git a/ghost/admin/views/post-item-view.js b/ghost/admin/views/post-item-view.js index 66c8f38bb7..5b283a8307 100644 --- a/ghost/admin/views/post-item-view.js +++ b/ghost/admin/views/post-item-view.js @@ -1,6 +1,14 @@ import itemView from 'ghost/views/item-view'; var PostItemView = itemView.extend({ + classNameBindings: ['isFeatured'], + + isFeatured: function () { + if (this.get('controller.model.featured')) { + return 'featured'; + } + }.property('controller.model.featured'), + openEditor: function () { this.get('controller').send('openEditor', this.get('controller.model')); // send action to handle transition to editor route }.on('doubleClick') From 6deb206e845e4e1043ffc7625bf2615e75b66fec Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 16 Jun 2014 09:38:29 +0000 Subject: [PATCH 2/2] Implements page class toggling. - Toggles page class when post is marked as static/non-static --- ghost/admin/controllers/posts/post.js | 2 +- ghost/admin/templates/posts.hbs | 1 - ghost/admin/views/post-item-view.js | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ghost/admin/controllers/posts/post.js b/ghost/admin/controllers/posts/post.js index 7bab3eea7a..84d0c6bf85 100644 --- a/ghost/admin/controllers/posts/post.js +++ b/ghost/admin/controllers/posts/post.js @@ -11,7 +11,7 @@ var PostController = Ember.ObjectController.extend({ this.get('model').save().then(function () { self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.'); - }, function() { + }, function () { self.notifications.showError('An error occured while saving the post.'); }); } diff --git a/ghost/admin/templates/posts.hbs b/ghost/admin/templates/posts.hbs index a0ba148d9f..5d34716772 100644 --- a/ghost/admin/templates/posts.hbs +++ b/ghost/admin/templates/posts.hbs @@ -9,7 +9,6 @@ {{#view "content-list-content-view" tagName="section"}}
    {{#each itemController="posts/post" itemView="post-item-view" itemTagName="li"}} - {{!-- @TODO: Restore functionality where 'featured' and 'page' classes are added for proper posts --}} {{#link-to "posts.post" this class="permalink" title="Edit this post"}}

    {{title}}