modal-controllers.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* eslint-disable
  2. n/handle-callback-err,
  3. max-len,
  4. no-return-assign,
  5. */
  6. // TODO: This file was created by bulk-decaffeinate.
  7. // Fix any style issues and re-enable lint.
  8. /*
  9. * decaffeinate suggestions:
  10. * DS102: Remove unnecessary code created because of implicit returns
  11. * DS207: Consider shorter variations of null checks
  12. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  13. */
  14. import App from '../../base'
  15. App.controller(
  16. 'CloneProjectModalController',
  17. function ($scope, $modalInstance, $timeout, project) {
  18. $scope.inputs = { projectName: project.name + ' (Copy)' }
  19. $scope.state = {
  20. inflight: false,
  21. error: false,
  22. }
  23. $modalInstance.opened.then(() =>
  24. $timeout(() => $scope.$broadcast('open'), 200)
  25. )
  26. $scope.clone = function () {
  27. $scope.state.inflight = true
  28. return $scope
  29. .cloneProject(project, $scope.inputs.projectName)
  30. .then(function () {
  31. $scope.state.inflight = false
  32. $scope.state.error = false
  33. return $modalInstance.close()
  34. })
  35. .catch(function (response) {
  36. const { data, status } = response
  37. $scope.state.inflight = false
  38. if (status === 400) {
  39. return ($scope.state.error = { message: data })
  40. } else {
  41. return ($scope.state.error = true)
  42. }
  43. })
  44. }
  45. return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
  46. }
  47. )
  48. App.controller(
  49. 'ArchiveTrashLeaveOrDeleteProjectsModalController',
  50. function ($scope, $modalInstance, $timeout, projects, action) {
  51. $scope.projects = projects
  52. $scope.action = action
  53. $scope.confirm = () => $modalInstance.close({ projects, action })
  54. $scope.cancel = () => $modalInstance.dismiss('cancel')
  55. }
  56. )