2020-04-06 07:45:56 -04:00
|
|
|
define(['../../../base'], App => {
|
2019-10-15 09:10:56 -04:00
|
|
|
App.controller('ShareProjectModalMemberRowController', function(
|
|
|
|
$scope,
|
2019-10-23 08:23:44 -04:00
|
|
|
$modal,
|
2019-10-15 09:10:56 -04:00
|
|
|
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
|
2019-10-23 08:23:44 -04:00
|
|
|
if (privilegeLevel === 'owner') {
|
|
|
|
openOwnershipTransferConfirmModal(userId)
|
|
|
|
} else {
|
|
|
|
setPrivilegeLevel(userId, privilegeLevel)
|
|
|
|
}
|
2019-10-15 09:10:56 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
this.privileges = $scope.member.privileges
|
|
|
|
$scope.clearError()
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 08:23:44 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|
2019-10-15 09:10:56 -04:00
|
|
|
})
|
|
|
|
})
|