2014-03-04 00:18:10 +04:00
|
|
|
var PostController = Ember.ObjectController.extend({
|
2014-05-31 22:32:22 +04:00
|
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
2014-06-16 09:44:07 +04:00
|
|
|
classNameBindings: ['featured'],
|
2014-05-21 17:53:00 +04:00
|
|
|
|
2014-04-20 18:48:34 +04:00
|
|
|
actions: {
|
2014-05-09 09:00:10 +04:00
|
|
|
toggleFeatured: function () {
|
2014-06-16 09:44:07 +04:00
|
|
|
var featured = !this.get('featured'),
|
|
|
|
self = this;
|
2014-05-09 09:00:10 +04:00
|
|
|
|
2014-06-16 09:44:07 +04:00
|
|
|
this.set('featured', featured);
|
|
|
|
|
|
|
|
this.get('model').save().then(function () {
|
|
|
|
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
|
2014-06-16 13:38:29 +04:00
|
|
|
}, function () {
|
2014-06-16 09:44:07 +04:00
|
|
|
self.notifications.showError('An error occured while saving the post.');
|
|
|
|
});
|
2014-04-20 18:48:34 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-04 00:18:10 +04:00
|
|
|
});
|
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
export default PostController;
|