Join/Leave buttons on guild detail page. Addresses #4427

This commit is contained in:
Kevin Gisi
2015-04-15 06:13:54 -04:00
parent c19ec1387a
commit d455666650
4 changed files with 21 additions and 2 deletions

View File

@@ -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

View File

@@ -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));

View File

@@ -260,7 +260,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
// reload the page. Perform manually.
$rootScope.hardRedirect = function(url){
window.location.href = url;
setTimeout(function() {
window.location.reload(false);
});
}
// Universal method for sending HTTP methods

View File

@@ -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')