2015-04-13 14:52:03 +09:00
|
|
|
|
Template.user_item.helpers({
|
2013-10-09 20:50:26 +09:00
|
|
|
|
createdAtFormatted: function(){
|
|
|
|
|
return this.createdAt ? moment(this.createdAt).fromNow() : '–';
|
|
|
|
|
},
|
2013-11-08 11:15:02 +09:00
|
|
|
|
getEmail: function(){
|
2015-04-20 13:57:37 +09:00
|
|
|
|
return Users.getEmail(this);
|
2013-10-09 20:50:26 +09:00
|
|
|
|
},
|
|
|
|
|
posts: function(){
|
|
|
|
|
return Posts.find({'userId':this._id});
|
|
|
|
|
},
|
|
|
|
|
comments: function(){
|
|
|
|
|
return Comments.find({'userId':this._id});
|
|
|
|
|
},
|
|
|
|
|
userIsAdmin: function(){
|
2015-04-27 17:14:07 +09:00
|
|
|
|
return Users.is.admin(this);
|
2013-10-26 10:37:32 +09:00
|
|
|
|
},
|
2013-11-14 10:49:37 +09:00
|
|
|
|
getProfileUrl: function () {
|
2015-04-20 13:57:37 +09:00
|
|
|
|
return Users.getProfileUrl(this);
|
2013-11-08 11:10:23 +09:00
|
|
|
|
},
|
|
|
|
|
getKarma: function() {
|
|
|
|
|
return Math.round(100*this.karma)/100;
|
2013-11-14 10:49:37 +09:00
|
|
|
|
},
|
|
|
|
|
getInvitedUserProfileUrl: function () {
|
|
|
|
|
var user = Meteor.users.findOne(this.invitedId);
|
2015-04-20 13:57:37 +09:00
|
|
|
|
return Users.getProfileUrl(user);
|
2013-10-09 20:50:26 +09:00
|
|
|
|
}
|
2012-10-05 13:59:40 +09:00
|
|
|
|
});
|
|
|
|
|
|
2015-04-13 14:52:03 +09:00
|
|
|
|
Template.user_item.events({
|
2013-10-09 20:50:26 +09:00
|
|
|
|
'click .invite-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2014-08-01 13:15:58 +02:00
|
|
|
|
Meteor.call('inviteUser', { userId : instance.data._id });
|
2013-10-09 20:50:26 +09:00
|
|
|
|
},
|
|
|
|
|
'click .uninvite-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
Meteor.users.update(instance.data._id,{
|
|
|
|
|
$set:{
|
|
|
|
|
isInvited: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .admin-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2015-04-20 13:57:37 +09:00
|
|
|
|
Users.updateAdmin(instance.data._id, true);
|
2013-10-09 20:50:26 +09:00
|
|
|
|
},
|
|
|
|
|
'click .unadmin-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2015-04-20 13:57:37 +09:00
|
|
|
|
Users.updateAdmin(instance.data._id, false);
|
2013-10-09 20:50:26 +09:00
|
|
|
|
},
|
|
|
|
|
'click .delete-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2015-04-20 13:57:37 +09:00
|
|
|
|
if(confirm(i18n.t("are_you_sure_you_want_to_delete")+Users.getDisplayName(instance.data)+"?"))
|
2013-10-09 20:50:26 +09:00
|
|
|
|
Meteor.users.remove(instance.data._id);
|
|
|
|
|
}
|
2014-10-03 16:21:06 -06:00
|
|
|
|
});
|