From 277225d8de4a01ed723b75e8264e93a4d4d8e7ff Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Tue, 18 Sep 2018 13:06:26 +0100 Subject: [PATCH] use existing left sidebar controller for affiliation cta --- services/web/app/views/project/list/side-bar.pug | 7 +++---- .../left-hand-menu-promo-controller.coffee | 12 +++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/services/web/app/views/project/list/side-bar.pug b/services/web/app/views/project/list/side-bar.pug index a35f702de7..067f870294 100644 --- a/services/web/app/views/project/list/side-bar.pug +++ b/services/web/app/views/project/list/side-bar.pug @@ -115,16 +115,15 @@ span(ng-controller="LeftHandMenuPromoController", ng-cloak) .row-spaced#userProfileInformation(ng-if="hasProjects") - div(ng-controller="UserAffiliationsController") - hr(ng-show="userEmails.length == 1 && userEmails[0].affiliations == null") - .text-centered.user-profile(ng-show="userEmails.length == 1 && userEmails[0].affiliations == null") + div(ng-show="userEmails.length > 0 && userAffiliations.length == 0", ng-cloak) + hr + .text-centered.user-profile p Are you affiliated with an institution? a.btn.btn-info( href="/user/settings" ) Add Affiliation - .row-spaced(ng-if="hasProjects && userHasNoSubscription", ng-cloak).text-centered hr p.small #{translate("on_free_sl")} diff --git a/services/web/public/coffee/main/project-list/left-hand-menu-promo-controller.coffee b/services/web/public/coffee/main/project-list/left-hand-menu-promo-controller.coffee index 9fdb3e9ca2..5606842a70 100644 --- a/services/web/public/coffee/main/project-list/left-hand-menu-promo-controller.coffee +++ b/services/web/public/coffee/main/project-list/left-hand-menu-promo-controller.coffee @@ -2,8 +2,18 @@ define [ "base" ], (App) -> - App.controller 'LeftHandMenuPromoController', ($scope) -> + App.controller 'LeftHandMenuPromoController', ($scope, UserAffiliationsDataService) -> $scope.hasProjects = window.data.projects.length > 0 $scope.userHasNoSubscription = window.userHasNoSubscription + _userHasNoAffiliation = () -> + $scope.userEmails = [] + $scope.userAffiliations = [] + UserAffiliationsDataService.getUserEmails().then (emails) -> + $scope.userEmails = emails + for email in emails + if email.affiliation + $scope.userAffiliations.push email.affiliation + + _userHasNoAffiliation()