overleaf/services/web/frontend/js/ide/share/controllers/ShareProjectModalMemberRowController.js
Alasdair Smith 8f5270899f Merge pull request #2707 from overleaf/as-transform-esm
Transform frontend module format from AMD to ESM

GitOrigin-RevId: 9adbcdc95e819a54114010c6fd3521d8f58ef2fe
2020-05-20 03:21:38 +00:00

47 lines
1.1 KiB
JavaScript

import App from '../../../base'
App.controller('ShareProjectModalMemberRowController', function(
$scope,
$modal,
projectMembers
) {
$scope.form = {
privileges: $scope.member.privileges,
isModified() {
return this.privileges !== $scope.member.privileges
},
submit() {
const userId = $scope.member._id
const privilegeLevel = $scope.form.privileges
if (privilegeLevel === 'owner') {
openOwnershipTransferConfirmModal(userId)
} else {
setPrivilegeLevel(userId, privilegeLevel)
}
},
reset() {
this.privileges = $scope.member.privileges
$scope.clearError()
}
}
function setPrivilegeLevel(userId, privilegeLevel) {
$scope.monitorRequest(
projectMembers
.setMemberPrivilegeLevel(userId, privilegeLevel)
.then(() => {
$scope.member.privileges = privilegeLevel
})
)
}
function openOwnershipTransferConfirmModal(userId) {
$modal.open({
templateUrl: 'ownershipTransferConfirmTemplate',
controller: 'OwnershipTransferConfirmModalController',
scope: $scope
})
}
})