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.inviter = User.user.profile.name;
$scope.emails = [{name:"",email:""},{name:"",email:""}]; $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(){ $scope.inviteEmails = function(){
Groups.Group.invite({gid: $scope.group._id}, {inviter: $scope.inviter, emails: $scope.emails}, 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(){ $scope.invite = function(){
var uuidList = _.pluck($scope.invitees,'uuid'); Groups.Group.invite({gid: $scope.group._id}, {uuids: [$scope.invitees.uuid]}, function(){
Groups.Group.invite({gid: $scope.group._id}, {uuids: uuidList}, function(){
Notification.text(window.env.t('invitationsSent')); Notification.text(window.env.t('invitationsSent'));
$scope.invitees = [{uuid:""},{uuid:""}]; $scope.invitees = {uuid:""};
}, function(){ }, function(){
$scope.invitees = [{uuid:""},{uuid:""}]; $scope.invitees = {uuid:""};
}); });
}; };
}]) }])

View File

@@ -6,7 +6,7 @@ script(type='text/ng-template', id='modals/invite-friends.html')
tabset tabset
tab(heading=env.t('inviteByEmail')) tab(heading=env.t('inviteByEmail'))
p.alert.alert-info=env.t('inviteByEmailExplanation') p.alert.alert-info=env.t('inviteByEmailExplanation')
form.form-horizontal(ng-submit='inviteEmails()') form.form-horizontal(ng-submit='inviteNewUsers("email")')
table.table.table-striped table.table.table-striped
thead thead
tr tr
@@ -31,19 +31,15 @@ script(type='text/ng-template', id='modals/invite-friends.html')
button.btn.btn-primary(type='submit')=env.t('sendInvitations') button.btn.btn-primary(type='submit')=env.t('sendInvitations')
tab(heading=env.t('inviteExistUser')) tab(heading=env.t('inviteExistUser'))
p.alert.alert-info!=env.t('inviteAlertInfo') p.alert.alert-info!=env.t('inviteAlertInfo')
form.form-horizontal(ng-submit='invite()') form.form-horizontal(ng-submit='inviteNewUsers("uuid")')
table.table.table-striped table.table.table-striped
thead thead
tr tr
th=env.t('userId') th=env.t('userId')
tbody tbody
tr(ng-repeat='invitee in invitees')
td
input.form-control(type='text', ng-model='invitee.uuid')
tr tr
td(colspan=2) td
a.btn.btn-xs.pull-right(ng-click='invitees = invitees.concat([{uuid:""}])') input.form-control(type='text', ng-model='invitees.uuid')
i.glyphicon.glyphicon-plus
tr tr
td td
.col-sm-1 .col-sm-1