use existing left sidebar controller for affiliation cta

This commit is contained in:
hugh-obrien 2018-09-18 13:06:26 +01:00
parent 26defd0833
commit 277225d8de
2 changed files with 14 additions and 5 deletions

View file

@ -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")}

View file

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