overleaf/services/web/frontend/js/ide/share/controllers/ShareProjectModalMemberRowController.js
Alasdair Smith bc1b73d74e Merge pull request #2515 from overleaf/as-transform-absolute-paths
Transform absolute paths in frontend to relative

GitOrigin-RevId: c1914c0fd09d68984ba6c85a1f00aa3e6858d944
2020-04-07 03:18:45 +00:00

48 lines
1.2 KiB
JavaScript

define(['../../../base'], App => {
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
})
}
})
})