2015-05-18 10:30:08 +09:00
|
|
|
Template.post_admin.helpers({
|
2015-02-11 19:29:07 +09:00
|
|
|
showApprove: function () {
|
2015-09-06 11:37:48 +09:00
|
|
|
return !!Settings.get('requirePostsApproval') && (this.status === Posts.config.STATUS_PENDING || this.status === Posts.config.STATUS_REJECTED);
|
2014-07-14 10:12:02 +09:00
|
|
|
},
|
2015-09-06 11:37:48 +09:00
|
|
|
showReject: function(){
|
|
|
|
return !!Settings.get('requirePostsApproval') && (this.status === Posts.config.STATUS_PENDING || this.status === Posts.config.STATUS_APPROVED);
|
2014-07-14 10:12:02 +09:00
|
|
|
},
|
2014-08-12 16:16:44 +09:00
|
|
|
shortScore: function(){
|
2015-08-18 10:21:21 +09:00
|
|
|
return Math.floor(this.score*100)/100;
|
2014-09-16 15:46:48 -04:00
|
|
|
}
|
2014-12-05 09:33:07 +09:00
|
|
|
});
|
|
|
|
|
2015-05-18 10:30:08 +09:00
|
|
|
Template.post_admin.events({
|
2015-05-01 18:22:00 +02:00
|
|
|
'click .approve-link': function(e){
|
2015-07-28 10:59:04 +09:00
|
|
|
Meteor.call('approvePost', this._id);
|
2014-12-05 09:33:07 +09:00
|
|
|
e.preventDefault();
|
2015-03-28 18:30:26 +09:00
|
|
|
},
|
2015-09-06 11:37:48 +09:00
|
|
|
'click .reject-link': function(e){
|
|
|
|
Meteor.call('rejectPost', this._id);
|
2014-12-05 09:33:07 +09:00
|
|
|
e.preventDefault();
|
2015-08-18 10:21:21 +09:00
|
|
|
},
|
|
|
|
'click .delete-link': function(e){
|
|
|
|
var post = this;
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if(confirm("Delete “"+post.title+"”?")){
|
2015-09-12 11:07:53 +09:00
|
|
|
Router.go('posts_default');
|
2015-08-18 10:21:21 +09:00
|
|
|
Meteor.call("deletePostById", post._id, function(error) {
|
|
|
|
if (error) {
|
|
|
|
console.log(error);
|
|
|
|
Messages.flash(error.reason, 'error');
|
|
|
|
} else {
|
|
|
|
Messages.flash(i18n.t('your_post_has_been_deleted'), 'success');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-12-05 09:33:07 +09:00
|
|
|
}
|
2015-08-18 10:21:21 +09:00
|
|
|
});
|