2014-12-29 21:11:24 -05:00
|
|
|
var PostController = Ember.Controller.extend({
|
|
|
|
isPublished: Ember.computed.equal('model.status', 'published'),
|
|
|
|
classNameBindings: ['model.featured'],
|
2014-05-21 08:53:00 -05:00
|
|
|
|
2014-12-16 11:55:45 -05:00
|
|
|
authorName: Ember.computed('model.author.name', 'model.author.email', function () {
|
|
|
|
return this.get('model.author.name') || this.get('model.author.email');
|
|
|
|
}),
|
|
|
|
|
|
|
|
authorAvatar: Ember.computed('model.author.image', function () {
|
|
|
|
return this.get('model.author.image') || this.get('ghostPaths.url').asset('/shared/img/user-image.png');
|
|
|
|
}),
|
|
|
|
|
2015-01-28 11:30:03 -05:00
|
|
|
authorAvatarBackground: Ember.computed('authorAvatar', function () {
|
|
|
|
return 'background-image: url(' + this.get('authorAvatar') + ')';
|
|
|
|
}),
|
|
|
|
|
2014-04-20 09:48:34 -05:00
|
|
|
actions: {
|
2014-05-09 00:00:10 -05:00
|
|
|
toggleFeatured: function () {
|
2014-07-14 23:02:34 -05:00
|
|
|
var options = {disableNProgress: true},
|
2014-06-16 00:44:07 -05:00
|
|
|
self = this;
|
2014-05-09 00:00:10 -05:00
|
|
|
|
2014-12-29 21:11:24 -05:00
|
|
|
this.toggleProperty('model.featured');
|
2014-07-14 23:02:34 -05:00
|
|
|
this.get('model').save(options).catch(function (errors) {
|
2014-06-20 16:36:44 -05:00
|
|
|
self.notifications.showErrors(errors);
|
2014-06-16 00:44:07 -05:00
|
|
|
});
|
2014-09-09 20:22:11 -05:00
|
|
|
},
|
|
|
|
showPostContent: function () {
|
2014-09-15 23:55:37 -05:00
|
|
|
this.transitionToRoute('posts.post', this.get('model'));
|
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;
|