2020-05-19 05:02:56 -04:00
|
|
|
import App from '../../../base'
|
2021-04-14 09:17:21 -04:00
|
|
|
App.controller(
|
|
|
|
'ShareProjectModalMemberRowController',
|
|
|
|
function ($scope, $modal, projectMembers) {
|
|
|
|
$scope.form = {
|
|
|
|
privileges: $scope.member.privileges,
|
2019-10-15 09:10:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
isModified() {
|
|
|
|
return this.privileges !== $scope.member.privileges
|
|
|
|
},
|
2019-10-15 09:10:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
submit() {
|
|
|
|
const userId = $scope.member._id
|
|
|
|
const privilegeLevel = $scope.form.privileges
|
|
|
|
if (privilegeLevel === 'owner') {
|
|
|
|
openOwnershipTransferConfirmModal(userId)
|
|
|
|
} else {
|
|
|
|
setPrivilegeLevel(userId, privilegeLevel)
|
|
|
|
}
|
|
|
|
},
|
2019-10-23 08:23:44 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
reset() {
|
|
|
|
this.privileges = $scope.member.privileges
|
|
|
|
$scope.clearError()
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2019-10-23 08:23:44 -04:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
function setPrivilegeLevel(userId, privilegeLevel) {
|
|
|
|
$scope.monitorRequest(
|
|
|
|
projectMembers
|
|
|
|
.setMemberPrivilegeLevel(userId, privilegeLevel)
|
|
|
|
.then(() => {
|
|
|
|
$scope.member.privileges = privilegeLevel
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
function openOwnershipTransferConfirmModal(userId) {
|
|
|
|
$modal.open({
|
|
|
|
templateUrl: 'ownershipTransferConfirmTemplate',
|
|
|
|
controller: 'OwnershipTransferConfirmModalController',
|
2021-04-27 03:52:58 -04:00
|
|
|
scope: $scope,
|
2021-04-14 09:17:21 -04:00
|
|
|
})
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|