Vulcan/packages/telescope-users/lib/client/templates/profile/user_info.js

30 lines
1,008 B
JavaScript
Raw Normal View History

Template.userInfo.helpers({
2014-12-08 14:53:26 +09:00
canEditProfile: function() {
var currentUser = Meteor.user();
2015-04-27 17:14:07 +09:00
return currentUser && (this._id == currentUser._id || Users.is.admin(currentUser));
2014-12-08 14:53:26 +09:00
},
createdAtFormatted: function() {
return this.createdAt;
},
canInvite: function() {
// if the user is logged in, the target user hasn't been invited yet, invites are enabled, and user is not viewing their own profile
2015-04-27 17:14:07 +09:00
return Meteor.user() && Meteor.user()._id != this._id && !Users.is.invited(this) && Telescope.utils.invitesEnabled() && Users.can.invite(Meteor.user());
2014-12-08 14:53:26 +09:00
},
inviteCount: function() {
return Meteor.user().inviteCount;
},
getTwitterName: function () {
return Users.getTwitterName(this);
2014-12-08 14:53:26 +09:00
},
getGitHubName: function () {
return Users.getGitHubName(this);
2014-12-08 14:53:26 +09:00
}
});
Template.userInfo.events({
2014-12-08 14:53:26 +09:00
'click .invite-link': function(e, instance){
Meteor.call('inviteUser', instance.data.user._id);
2015-03-27 16:24:21 +08:00
Messages.flash('Thanks, user has been invited.', "success");
2014-12-08 14:53:26 +09:00
}
});