mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Split out group controllers into separate files
This commit is contained in:
41
website/public/js/controllers/inviteToGroupCtrl.js
Normal file
41
website/public/js/controllers/inviteToGroupCtrl.js
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedGroup', '$http', 'Notification', function($scope, User, Groups, injectedGroup, $http, Notification) {
|
||||
$scope.group = injectedGroup;
|
||||
|
||||
$scope.inviter = User.user.profile.name;
|
||||
$scope.emails = [{name:"",email:""},{name:"",email:""}];
|
||||
$scope.invitees = {uuid:""};
|
||||
|
||||
$scope.inviteNewUsers = function(inviteMethod) {
|
||||
if (!$scope.group._id) {
|
||||
group.create($scope.newGroup, function() {
|
||||
_inviteByMethod(inviteMethod);
|
||||
});
|
||||
} else {
|
||||
_inviteByMethod(inviteMethod);
|
||||
}
|
||||
};
|
||||
|
||||
function _inviteByMethod(inviteMethod) {
|
||||
if (inviteMethod === 'email') {
|
||||
Groups.Group.invite({gid: $scope.group._id}, {inviter: $scope.inviter, emails: $scope.emails}, function(){
|
||||
Notification.text(window.env.t('invitationsSent'));
|
||||
$scope.emails = [{name:'',email:''},{name:'',email:''}];
|
||||
}, function(){
|
||||
$scope.emails = [{name:'',email:''},{name:'',email:''}];
|
||||
});
|
||||
}
|
||||
else if (inviteMethod === 'uuid') {
|
||||
Groups.Group.invite({gid: $scope.group._id}, {uuids: [$scope.invitees.uuid]}, function(){
|
||||
Notification.text(window.env.t('invitationsSent'));
|
||||
$scope.invitees = {uuid:""};
|
||||
}, function(){
|
||||
$scope.invitees = {uuid:""};
|
||||
});
|
||||
}
|
||||
else {
|
||||
return console.log('Invalid invite method.')
|
||||
}
|
||||
}
|
||||
}]);
|
||||
Reference in New Issue
Block a user