2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
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 07:53:00 -06:00
|
|
|
|
2014-12-16 16:55:45 +00: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 16:30:03 +00:00
|
|
|
authorAvatarBackground: Ember.computed('authorAvatar', function () {
|
|
|
|
return 'background-image: url(' + this.get('authorAvatar') + ')';
|
|
|
|
}),
|
|
|
|
|
2014-04-20 08:48:34 -06:00
|
|
|
actions: {
|
2014-05-09 00:00:10 -05:00
|
|
|
toggleFeatured: function () {
|
2014-07-14 22:02:34 -06:00
|
|
|
var options = {disableNProgress: true},
|
2014-06-16 05:44:07 +00: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 22:02:34 -06:00
|
|
|
this.get('model').save(options).catch(function (errors) {
|
2014-06-20 17:36:44 -04:00
|
|
|
self.notifications.showErrors(errors);
|
2014-06-16 05:44:07 +00:00
|
|
|
});
|
2014-09-09 19:22:11 -06:00
|
|
|
},
|
|
|
|
showPostContent: function () {
|
2014-09-15 22:55:37 -06:00
|
|
|
this.transitionToRoute('posts.post', this.get('model'));
|
2014-04-20 08:48:34 -06:00
|
|
|
}
|
|
|
|
}
|
2014-03-03 21:18:10 +01:00
|
|
|
});
|
|
|
|
|
2014-06-29 23:45:03 +02:00
|
|
|
export default PostController;
|