Filter out blank emails

This commit is contained in:
Blade Barringer
2015-08-21 21:39:04 -05:00
parent 59dc0cdb4f
commit 07b9b35234
2 changed files with 39 additions and 4 deletions

View File

@@ -20,7 +20,9 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedG
function _inviteByMethod(inviteMethod) {
if (inviteMethod === 'email') {
Groups.Group.invite({gid: $scope.group._id}, {inviter: $scope.inviter, emails: $scope.emails}, function(){
var emails = _getEmails();
Groups.Group.invite({gid: $scope.group._id}, {inviter: $scope.inviter, emails: emails}, function(){
Notification.text(window.env.t('invitationsSent'));
_resetInvitees();
}, function(){
@@ -49,6 +51,14 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedG
return filteredUuids;
}
function _getEmails() {
var emails = _.filter($scope.emails, function(obj) {
return obj.email != '';
});
console.log(emails);
return emails;
}
function _resetInvitees() {
var emptyEmails = [{name:"",email:""},{name:"",email:""}];
var emptyInvitees = [{uuid: ''}];