2018-11-05 05:06:39 -05:00
|
|
|
define(['base'], App =>
|
|
|
|
App.controller('LeftHandMenuPromoController', function(
|
|
|
|
$scope,
|
2020-02-03 09:11:36 -05:00
|
|
|
UserAffiliationsDataService,
|
|
|
|
eventTracking
|
2018-11-05 05:06:39 -05:00
|
|
|
) {
|
|
|
|
$scope.hasProjects = window.data.projects.length > 0
|
|
|
|
$scope.userHasNoSubscription = window.userHasNoSubscription
|
|
|
|
|
2020-02-03 09:11:36 -05:00
|
|
|
$scope.upgradeSubscription = function() {
|
|
|
|
eventTracking.send('subscription-funnel', 'project-page', 'upgrade')
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.share = function() {
|
|
|
|
eventTracking.send('subscription-funnel', 'project-page', 'sharing')
|
|
|
|
}
|
|
|
|
|
2018-11-05 05:06:39 -05:00
|
|
|
const _userHasNoAffiliation = function() {
|
|
|
|
$scope.userEmails = []
|
|
|
|
$scope.userAffiliations = []
|
|
|
|
return UserAffiliationsDataService.getUserEmails().then(function(emails) {
|
|
|
|
$scope.userEmails = emails
|
2019-01-24 06:47:35 -05:00
|
|
|
$scope.userAffiliations = emails
|
|
|
|
.filter(email => email.affiliation)
|
|
|
|
.map(email => email.affiliation)
|
|
|
|
$scope.userOnPayingUniversity = $scope.userAffiliations.some(
|
|
|
|
affiliation => affiliation.institution.licence !== 'free'
|
|
|
|
)
|
2018-11-05 05:06:39 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-01-24 06:47:35 -05:00
|
|
|
_userHasNoAffiliation()
|
2018-11-05 05:06:39 -05:00
|
|
|
}))
|