2014-03-03 15:18:10 -05:00
|
|
|
var PostController = Ember.ObjectController.extend({
|
2014-05-31 13:32:22 -05:00
|
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
2014-06-16 00:44:07 -05:00
|
|
|
classNameBindings: ['featured'],
|
2014-05-21 08:53:00 -05:00
|
|
|
|
2014-04-20 09:48:34 -05:00
|
|
|
actions: {
|
2014-05-09 00:00:10 -05:00
|
|
|
toggleFeatured: function () {
|
2014-06-17 15:20:54 -05:00
|
|
|
var featured = this.toggleProperty('featured'),
|
2014-06-16 00:44:07 -05:00
|
|
|
self = this;
|
2014-05-09 00:00:10 -05:00
|
|
|
|
2014-06-16 00:44:07 -05:00
|
|
|
this.get('model').save().then(function () {
|
2014-07-01 22:34:46 -05:00
|
|
|
self.notifications.closePassive();
|
2014-06-16 00:44:07 -05:00
|
|
|
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
|
2014-06-20 16:36:44 -05:00
|
|
|
}).catch(function (errors) {
|
2014-07-01 22:34:46 -05:00
|
|
|
self.notifications.closePassive();
|
2014-06-20 16:36:44 -05:00
|
|
|
self.notifications.showErrors(errors);
|
2014-06-16 00:44:07 -05:00
|
|
|
});
|
2014-04-20 09:48:34 -05:00
|
|
|
}
|
|
|
|
}
|
2014-03-03 15:18:10 -05:00
|
|
|
});
|
|
|
|
|
2014-06-29 16:45:03 -05:00
|
|
|
export default PostController;
|