Vulcan/client/views/users/invites.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-07-31 01:18:17 +02:00
Template[getTemplate('invites')].helpers({
canCurrentUserInvite: function(){
var currentUser = Meteor.user();
return currentUser && (currentUser.inviteCount > 0 && canInvite(currentUser));
},
invitesLeft: function(){
var currentUser = Meteor.user();
return currentUser ? currentUser.inviteCount : 0;
},
invitesSchema: function() {
// expose schema for Invites (used by AutoForm)
return InviteSchema;
}
});
var scrollUp = function(){
Deps.afterFlush(function() {
var element = $('.grid > .error');
$('html, body').animate({scrollTop: element.offset().top});
});
};
AutoForm.hooks({
inviteForm: {
onSuccess: function(operation, result, template) {
clearSeenErrors();
if(result && result.newUser){
2014-08-02 14:06:28 +02:00
throwError('An invite has been sent out. Thank you!');
} else {
throwError('Thank you!');
}
scrollUp();
},
onError: function(operation, error, template) {
clearSeenErrors();
if(error && error.reason){
throwError(error.reason);
scrollUp();
}
}
}
2014-07-31 01:18:17 +02:00
});