From 1858f8fb64af6ab544b51ae30aee650aa75b8e35 Mon Sep 17 00:00:00 2001 From: Jessy Kate Schingler Date: Wed, 19 Jul 2017 17:44:17 +0200 Subject: [PATCH] keep sidebar group list to groups the super admin is really a member of --- .../group-page-sidenav/group-page-sidenav.coffee | 2 +- app/models/user-model.coffee | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/directives/group-page-sidenav/group-page-sidenav.coffee b/app/directives/group-page-sidenav/group-page-sidenav.coffee index 2a74e3e3..863972f6 100644 --- a/app/directives/group-page-sidenav/group-page-sidenav.coffee +++ b/app/directives/group-page-sidenav/group-page-sidenav.coffee @@ -11,7 +11,7 @@ global.cobudgetApp.directive 'groupPageSidenav', () -> $mdSidenav('left').open() $scope.accessibleGroups = -> - CurrentUser() && CurrentUser().groups() + CurrentUser() && CurrentUser().groupsToDisplay() $scope.redirectToGroupPage = (groupId) -> if $state.current.name == 'group' && $scope.group.id == parseInt(groupId) diff --git a/app/models/user-model.coffee b/app/models/user-model.coffee index a4647812..f29b5b4f 100644 --- a/app/models/user-model.coffee +++ b/app/models/user-model.coffee @@ -20,6 +20,14 @@ global.cobudgetApp.factory 'UserModel', (BaseModel) -> @hasMany 'memberships', with: 'memberId' @belongsTo 'subscriptionTracker' + groupsToDisplay: () -> + selectMemberships = _.filter @memberships(), (membership) -> + membership.id + + groupIds = _.map selectMemberships, (membership) -> + membership.groupId + @recordStore.groups.find(groupIds) + groups: () -> groupIds = _.map @memberships(), (membership) -> membership.groupId