WIP(party-page): Roll back to 1x invites

Also a draft of logic for 1-step create group + invite people.
This commit is contained in:
Sabe Jones
2015-08-12 11:29:36 -05:00
parent 5b15d603aa
commit 2d8fdab496
2 changed files with 30 additions and 13 deletions

View File

@@ -139,7 +139,29 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
$scope.inviter = User.user.profile.name;
$scope.emails = [{name:"",email:""},{name:"",email:""}];
$scope.invitees = [{uuid:""},{uuid:""}];
$scope.invitees = {uuid:""};
$scope.inviteNewUsers = function(inviteMethod){
if (!$scope.group) {
Groups.group.create($scope.newGroup, function() {
inviteByMethod(inviteMethod);
});
} else {
inviteByMethod(inviteMethod);
}
};
var inviteByMethod = function(inviteMethod) {
if (inviteMethod === 'email') {
inviteEmails();
}
else if (inviteMethod === 'uuid') {
invite();
}
else {
return console.log('Invalid invite method.')
}
};
$scope.inviteEmails = function(){
Groups.Group.invite({gid: $scope.group._id}, {inviter: $scope.inviter, emails: $scope.emails}, function(){
@@ -151,12 +173,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
};
$scope.invite = function(){
var uuidList = _.pluck($scope.invitees,'uuid');
Groups.Group.invite({gid: $scope.group._id}, {uuids: uuidList}, function(){
Groups.Group.invite({gid: $scope.group._id}, {uuids: [$scope.invitees.uuid]}, function(){
Notification.text(window.env.t('invitationsSent'));
$scope.invitees = [{uuid:""},{uuid:""}];
$scope.invitees = {uuid:""};
}, function(){
$scope.invitees = [{uuid:""},{uuid:""}];
$scope.invitees = {uuid:""};
});
};
}])