OwnershipTransferConfirmModalController.js 854 B

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