OwnershipTransferConfirmModalController.js 845 B

1234567891011121314151617181920212223242526272829303132333435
  1. import App from '../../../base'
  2. App.controller(
  3. 'OwnershipTransferConfirmModalController',
  4. function ($scope, $window, $modalInstance, projectMembers) {
  5. $scope.state = {
  6. inflight: false,
  7. error: false,
  8. }
  9. $scope.confirm = function () {
  10. const userId = $scope.member._id
  11. transferOwnership(userId)
  12. }
  13. $scope.cancel = function () {
  14. $modalInstance.dismiss()
  15. }
  16. function transferOwnership(userId) {
  17. $scope.state.inflight = true
  18. $scope.state.error = false
  19. projectMembers
  20. .transferOwnership(userId)
  21. .then(() => {
  22. $scope.state.inflight = false
  23. $scope.state.error = false
  24. $window.location.reload()
  25. })
  26. .catch(() => {
  27. $scope.state.inflight = false
  28. $scope.state.error = true
  29. })
  30. }
  31. }
  32. )