mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
When a user leaves a group, remove them from all group challenges
This commit is contained in:
@@ -192,8 +192,8 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
|
||||
}])
|
||||
|
||||
.controller("GuildsCtrl", ['$scope', 'Groups', 'User', '$rootScope', '$state', '$location',
|
||||
function($scope, Groups, User, $rootScope, $state, $location) {
|
||||
.controller("GuildsCtrl", ['$scope', 'Groups', 'User', '$rootScope', '$state', '$location', '$compile',
|
||||
function($scope, Groups, User, $rootScope, $state, $location, $compile) {
|
||||
$scope.groups = {
|
||||
guilds: Groups.myGuilds(),
|
||||
"public": Groups.publicGuilds()
|
||||
@@ -238,11 +238,12 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
})
|
||||
}
|
||||
|
||||
$scope.leave = function(group){
|
||||
if (confirm("Are you sure you want to leave this guild?") !== true) {
|
||||
return;
|
||||
}
|
||||
Groups.Group.leave({gid: group._id}, undefined, function(){
|
||||
$scope.leave = function(keep) {
|
||||
if (keep == 'cancel') {
|
||||
$scope.selectedChal = undefined;
|
||||
} else {
|
||||
var group = $scope.selectedGroup;
|
||||
Groups.Group.leave({gid: group._id, keep:keep}, undefined, function(){
|
||||
$scope.groups.guilds.splice(_.indexOf($scope.groups.guilds, group), 1);
|
||||
// remove user from group members if guild is public so that he can re-join it immediately
|
||||
if(group.privacy == 'public' || !group.privacy){ //public guilds with only some fields fetched
|
||||
@@ -256,6 +257,23 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
$state.go('options.social.guilds');
|
||||
});
|
||||
}
|
||||
$scope.popoverEl.popover('destroy');
|
||||
}
|
||||
|
||||
$scope.clickLeave = function(group, $event){
|
||||
$scope.selectedGroup = group;
|
||||
$scope.popoverEl = $($event.target);
|
||||
var html = $compile(
|
||||
'<a ng-controller="GroupsCtrl" ng-click="leave(\'remove-all\')">Remove Tasks</a><br/>\n<a ng-click="leave(\'keep-all\')">Keep Tasks</a><br/>\n<a ng-click="leave(\'cancel\')">Cancel</a><br/>'
|
||||
)($scope);
|
||||
$scope.popoverEl.popover('destroy').popover({
|
||||
html: true,
|
||||
placement: 'top',
|
||||
trigger: 'manual',
|
||||
title: 'Leaving group challenges and...',
|
||||
content: html
|
||||
}).popover('show');
|
||||
}
|
||||
|
||||
$scope.reject = function(guild){
|
||||
var i = _.findIndex(User.user.invitations.guilds, {id:guild.id});
|
||||
|
||||
Reference in New Issue
Block a user