2020-05-19 05:02:56 -04:00
|
|
|
import App from '../../../base'
|
2021-04-14 09:17:21 -04:00
|
|
|
App.controller(
|
|
|
|
'OwnershipTransferConfirmModalController',
|
|
|
|
function ($scope, $window, $modalInstance, projectMembers) {
|
|
|
|
$scope.state = {
|
|
|
|
inflight: false,
|
|
|
|
error: false
|
|
|
|
}
|
2019-10-23 08:23:44 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.confirm = function () {
|
|
|
|
const userId = $scope.member._id
|
|
|
|
transferOwnership(userId)
|
|
|
|
}
|
2019-10-23 08:23:44 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.cancel = function () {
|
|
|
|
$modalInstance.dismiss()
|
|
|
|
}
|
2019-10-23 08:23:44 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
function transferOwnership(userId) {
|
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope.state.error = false
|
|
|
|
projectMembers
|
|
|
|
.transferOwnership(userId)
|
|
|
|
.then(() => {
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$window.location.reload()
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = true
|
|
|
|
})
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|