From 59008b4a5161ada8f2f2fecca5cd9a830abda343 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 6 Jul 2018 13:45:34 +0100 Subject: [PATCH] Show university custom departments when changing affiliations; fix Features typo. --- services/web/app/coffee/infrastructure/Features.coffee | 2 +- .../controllers/UserAffiliationsController.coffee | 6 ++++++ .../factories/UserAffiliationsDataService.coffee | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/infrastructure/Features.coffee b/services/web/app/coffee/infrastructure/Features.coffee index bf7d37d773..311d8943c9 100644 --- a/services/web/app/coffee/infrastructure/Features.coffee +++ b/services/web/app/coffee/infrastructure/Features.coffee @@ -21,6 +21,6 @@ module.exports = Features = when 'templates' return !Settings.overleaf? when 'affiliations' - return settings?.apis?.v1?.url? + return Settings?.apis?.v1?.url? else throw new Error("unknown feature: #{feature}") diff --git a/services/web/public/coffee/main/affiliations/controllers/UserAffiliationsController.coffee b/services/web/public/coffee/main/affiliations/controllers/UserAffiliationsController.coffee index 8b7a5c926f..dd23f72c0a 100644 --- a/services/web/public/coffee/main/affiliations/controllers/UserAffiliationsController.coffee +++ b/services/web/public/coffee/main/affiliations/controllers/UserAffiliationsController.coffee @@ -47,6 +47,10 @@ define [ $scope.ui.showManualUniversitySelectionUI = true $scope.changeAffiliation = (userEmail) -> + if userEmail.affiliation?.institution?.id? + UserAffiliationsDataService.getUniversityDetails userEmail.affiliation.institution.id + .then (universityDetails) -> $scope.affiliationToChange.university = universityDetails + $scope.affiliationToChange.email = userEmail.email $scope.affiliationToChange.role = userEmail.affiliation.role $scope.affiliationToChange.department = userEmail.affiliation.department @@ -64,6 +68,7 @@ define [ $scope.cancelAffiliationChange = (email) -> $scope.affiliationToChange.email = "" + $scope.affiliationToChange.university = null $scope.affiliationToChange.role = null $scope.affiliationToChange.department = null @@ -142,6 +147,7 @@ define [ isBlacklistedEmail: false $scope.affiliationToChange = email: "" + university: null role: null department: null _reset() diff --git a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee index ae043bbda9..38e5c4e96c 100644 --- a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee +++ b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee @@ -53,6 +53,10 @@ define [ else $q.reject null + getUniversityDetails = (universityId) -> + $http.get "/institutions/list/#{ universityId }" + .then (response) -> response.data + addUserEmail = (email) -> $http.post "/user/emails", { email, @@ -110,6 +114,7 @@ define [ getUserEmails getUniversitiesFromCountry getUniversityDomainFromPartialDomainInput + getUniversityDetails addUserEmail addUserAffiliationWithUnknownUniversity addUserAffiliation