diff --git a/core/client/controllers/posts/post.js b/core/client/controllers/posts/post.js index 82ede268f7..84d0c6bf85 100644 --- a/core/client/controllers/posts/post.js +++ b/core/client/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/core/client/templates/posts.hbs b/core/client/templates/posts.hbs index a0ba148d9f..5d34716772 100644 --- a/core/client/templates/posts.hbs +++ b/core/client/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}}

    diff --git a/core/client/views/post-item-view.js b/core/client/views/post-item-view.js index 66c8f38bb7..99ac893d43 100644 --- a/core/client/views/post-item-view.js +++ b/core/client/views/post-item-view.js @@ -1,6 +1,20 @@ import itemView from 'ghost/views/item-view'; var PostItemView = itemView.extend({ + classNameBindings: ['isFeatured', 'isPage'], + + isFeatured: function () { + if (this.get('controller.model.featured')) { + return 'featured'; + } + }.property('controller.model.featured'), + + isPage: function () { + if (this.get('controller.model.page')) { + return 'page'; + } + }.property('controller.model.page'), + openEditor: function () { this.get('controller').send('openEditor', this.get('controller.model')); // send action to handle transition to editor route }.on('doubleClick')