mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Join/Leave buttons on guild detail page. Addresses #4427
This commit is contained in:
@@ -44,6 +44,11 @@ a.hint:hover
|
||||
ul
|
||||
padding-left: 10px
|
||||
|
||||
.group-leave-join
|
||||
.glyphicon-ban-circle
|
||||
color: white;
|
||||
margin-right: 5px;
|
||||
|
||||
@media (max-width: 768px)
|
||||
.container-fluid
|
||||
padding-right: 5px
|
||||
|
||||
@@ -16,6 +16,15 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
}
|
||||
|
||||
$scope.isMemberOfGroup = function(userid, group){
|
||||
|
||||
// If the group is a guild, just check for an intersection with the
|
||||
// current user's guilds, rather than checking the members of the group.
|
||||
if(group.type === 'guild') {
|
||||
if (_.detect(Groups.myGuilds(), function(g) { return g._id === group._id })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!group.members) return false;
|
||||
var memberIds = _.map(group.members, function(x){return x._id});
|
||||
return ~(memberIds.indexOf(userid));
|
||||
|
||||
@@ -260,7 +260,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
// reload the page. Perform manually.
|
||||
$rootScope.hardRedirect = function(url){
|
||||
window.location.href = url;
|
||||
window.location.reload(false);
|
||||
setTimeout(function() {
|
||||
window.location.reload(false);
|
||||
});
|
||||
}
|
||||
|
||||
// Universal method for sending HTTP methods
|
||||
|
||||
@@ -17,7 +17,10 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
|
||||
.panel-heading(bindonce='group')
|
||||
h3.panel-title
|
||||
| {{group.name}}
|
||||
span(ng-if='group')
|
||||
span.group-leave-join(ng-if='group')
|
||||
a.btn.btn-sm.btn-danger.pull-right(ng-if=":: isMemberOfGroup(User.user._id, group)", ng-click='clickLeave(group, $event)')
|
||||
span.glyphicon.glyphicon-ban-circle
|
||||
=env.t('leave')
|
||||
a.btn.btn-success.pull-right(ng-if=':: !isMemberOfGroup(User.user._id, group)', ng-click='join(group)')=env.t('join')
|
||||
span(ng-if='group.leader == user.id')
|
||||
button.btn.btn-primary.pull-right(ng-click='save(group)', ng-show='group._editing')=env.t('save')
|
||||
|
||||
Reference in New Issue
Block a user