mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-03 15:02:50 +00:00
Integrate e-mails table with backend.
This commit is contained in:
parent
917776aede
commit
147d74d92a
3 changed files with 37 additions and 26 deletions
|
@ -234,13 +234,11 @@ block content
|
||||||
th Institution and role
|
th Institution and role
|
||||||
th
|
th
|
||||||
tbody
|
tbody
|
||||||
tr
|
tr(
|
||||||
td paulojreis@ua.pt
|
ng-repeat="userEmail in userEmails"
|
||||||
td Universidade de Aveiro
|
)
|
||||||
td Remove
|
td {{ userEmail.email + (userEmail.default ? ' (default)' : '') }}
|
||||||
tr
|
td {{ userEmail.institution }}
|
||||||
td paulojreis@fe.up.pt
|
|
||||||
td Universidade do Porto
|
|
||||||
td Remove
|
td Remove
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ define [
|
||||||
"base"
|
"base"
|
||||||
], (App) ->
|
], (App) ->
|
||||||
App.controller "UserAffiliationsController", ["$scope", "UserAffiliationsDataService", "$q", ($scope, UserAffiliationsDataService, $q) ->
|
App.controller "UserAffiliationsController", ["$scope", "UserAffiliationsDataService", "$q", ($scope, UserAffiliationsDataService, $q) ->
|
||||||
|
$scope.userEmails = []
|
||||||
$scope.countries = []
|
$scope.countries = []
|
||||||
$scope.universities = []
|
$scope.universities = []
|
||||||
$scope.newAffiliation =
|
$scope.newAffiliation =
|
||||||
|
@ -24,8 +25,6 @@ define [
|
||||||
else
|
else
|
||||||
{ local: null, domain: null }
|
{ local: null, domain: null }
|
||||||
|
|
||||||
UserAffiliationsDataService.getUserEmails()
|
|
||||||
|
|
||||||
$scope.addUniversityToSelection = (universityName) ->
|
$scope.addUniversityToSelection = (universityName) ->
|
||||||
{ name: universityName, isUserSuggested: true }
|
{ name: universityName, isUserSuggested: true }
|
||||||
|
|
||||||
|
@ -66,23 +65,34 @@ define [
|
||||||
|
|
||||||
$scope.handleAffiliationFormSubmit = () ->
|
$scope.handleAffiliationFormSubmit = () ->
|
||||||
if !$scope.newAffiliation.university?
|
if !$scope.newAffiliation.university?
|
||||||
UserAffiliationsDataService.addUserEmail $scope.newAffiliation.email
|
addEmailPromise = UserAffiliationsDataService
|
||||||
|
.addUserEmail $scope.newAffiliation.email
|
||||||
else
|
else
|
||||||
if $scope.newAffiliation.university.isUserSuggested
|
if $scope.newAffiliation.university.isUserSuggested
|
||||||
UserAffiliationsDataService.addUserAffiliationWithUnknownUniversity(
|
addEmailPromise = UserAffiliationsDataService
|
||||||
$scope.newAffiliation.email,
|
.addUserAffiliationWithUnknownUniversity(
|
||||||
$scope.newAffiliation.university.name,
|
$scope.newAffiliation.email,
|
||||||
$scope.newAffiliation.country.code,
|
$scope.newAffiliation.university.name,
|
||||||
$scope.newAffiliation.role,
|
$scope.newAffiliation.country.code,
|
||||||
$scope.newAffiliation.department
|
$scope.newAffiliation.role,
|
||||||
)
|
$scope.newAffiliation.department
|
||||||
|
)
|
||||||
else
|
else
|
||||||
UserAffiliationsDataService.addUserAffiliation(
|
addEmailPromise = UserAffiliationsDataService
|
||||||
$scope.newAffiliation.email,
|
.addUserAffiliation(
|
||||||
$scope.newAffiliation.university.id
|
$scope.newAffiliation.email,
|
||||||
$scope.newAffiliation.role,
|
$scope.newAffiliation.university.id
|
||||||
$scope.newAffiliation.department
|
$scope.newAffiliation.role,
|
||||||
)
|
$scope.newAffiliation.department
|
||||||
|
)
|
||||||
|
addEmailPromise.then () -> getUserEmails()
|
||||||
|
|
||||||
|
# Populates the emails table
|
||||||
|
getUserEmails = () ->
|
||||||
|
UserAffiliationsDataService
|
||||||
|
.getUserEmails()
|
||||||
|
.then (emails) -> $scope.userEmails = emails
|
||||||
|
getUserEmails()
|
||||||
|
|
||||||
# Populates the countries dropdown
|
# Populates the countries dropdown
|
||||||
UserAffiliationsDataService
|
UserAffiliationsDataService
|
||||||
|
|
|
@ -47,7 +47,8 @@ define [
|
||||||
|
|
||||||
addUserEmail = (email) ->
|
addUserEmail = (email) ->
|
||||||
$http.post "/user/emails", {
|
$http.post "/user/emails", {
|
||||||
email
|
email,
|
||||||
|
_csrf: window.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
addUserAffiliationWithUnknownUniversity = (email, unknownUniversityName, unknownUniversityCountryCode, role, department) ->
|
addUserAffiliationWithUnknownUniversity = (email, unknownUniversityName, unknownUniversityCountryCode, role, department) ->
|
||||||
|
@ -57,7 +58,8 @@ define [
|
||||||
name: unknownUniversityName
|
name: unknownUniversityName
|
||||||
country_code: unknownUniversityCountryCode
|
country_code: unknownUniversityCountryCode
|
||||||
role,
|
role,
|
||||||
department
|
department,
|
||||||
|
_csrf: window.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
addUserAffiliation = (email, universityId, role, department) ->
|
addUserAffiliation = (email, universityId, role, department) ->
|
||||||
|
@ -66,7 +68,8 @@ define [
|
||||||
university:
|
university:
|
||||||
id: universityId
|
id: universityId
|
||||||
role,
|
role,
|
||||||
department
|
department,
|
||||||
|
_csrf: window.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
isDomainBlacklisted = (domain) ->
|
isDomainBlacklisted = (domain) ->
|
||||||
|
|
Loading…
Reference in a new issue