Preemptively remove front-end data when removing user emails.

This commit is contained in:
Paulo Reis 2018-07-04 16:54:04 +01:00 committed by James Allen
parent 19b57571bf
commit c630c5d952
2 changed files with 9 additions and 6 deletions

View file

@ -59,13 +59,13 @@ form.row(
a(
href
ng-if="!userEmail.default"
ng-click="setDefaultUserEmail(userEmail.email)"
ng-click="setDefaultUserEmail(userEmail)"
) Make default
br
a(
href
ng-if="!userEmail.default"
ng-click="removeUserEmail(userEmail.email)"
ng-click="removeUserEmail(userEmail)"
) Remove
tr.affiliations-table-highlighted-row(
ng-if="ui.isLoadingEmails"

View file

@ -97,16 +97,19 @@ define [
_reset()
_getUserEmails()
$scope.setDefaultUserEmail = (email) ->
$scope.setDefaultUserEmail = (userEmail) ->
$scope.ui.isLoadingEmails = true
UserAffiliationsDataService
.setDefaultUserEmail email
.setDefaultUserEmail userEmail.email
.then () -> _getUserEmails()
$scope.removeUserEmail = (email) ->
$scope.removeUserEmail = (userEmail) ->
$scope.ui.isLoadingEmails = true
userEmailIdx = _.indexOf $scope.userEmails, userEmail
if userEmailIdx > -1
$scope.userEmails.splice userEmailIdx, 1
UserAffiliationsDataService
.removeUserEmail email
.removeUserEmail userEmail.email
.then () -> _getUserEmails()
_reset = () ->