2014-09-01 13:05:51 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-05-19 11:21:02 -04:00
|
|
|
App.controller 'RenameProjectModalController', ($scope, $modalInstance, $timeout, project, queuedHttp) ->
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.inputs =
|
2017-05-19 11:21:02 -04:00
|
|
|
projectName: project.name
|
|
|
|
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.rename = () ->
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope.state.error = false
|
|
|
|
$scope
|
|
|
|
.renameProject(project, $scope.inputs.projectName)
|
|
|
|
.success () ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
|
|
|
.error (body, statusCode) ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
if statusCode == 400
|
|
|
|
$scope.state.error = { message: body }
|
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'CloneProjectModalController', ($scope, $modalInstance, $timeout, project) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: project.name + " (Copy)"
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
2017-05-19 11:21:02 -04:00
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.clone = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope
|
|
|
|
.cloneProject(project, $scope.inputs.projectName)
|
2017-05-19 11:21:02 -04:00
|
|
|
.success () ->
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.state.inflight = false
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
|
|
|
.error (body, statusCode) ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
if statusCode == 400
|
|
|
|
$scope.state.error = { message: body }
|
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'NewProjectModalController', ($scope, $modalInstance, $timeout, template) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: ""
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
2017-05-19 11:21:02 -04:00
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.create = () ->
|
|
|
|
$scope.state.inflight = true
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.error = false
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope
|
|
|
|
.createProject($scope.inputs.projectName, template)
|
2017-05-19 11:21:02 -04:00
|
|
|
.success (data) ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close(data.project_id)
|
|
|
|
.error (body, statusCode) ->
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.state.inflight = false
|
2017-05-19 11:21:02 -04:00
|
|
|
if statusCode == 400
|
|
|
|
$scope.state.error = { message: body }
|
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'DeleteProjectsModalController', ($scope, $modalInstance, $timeout, projects) ->
|
|
|
|
$scope.projectsToDelete = projects.filter (project) -> project.accessLevel == "owner"
|
|
|
|
$scope.projectsToLeave = projects.filter (project) -> project.accessLevel != "owner"
|
|
|
|
|
|
|
|
if $scope.projectsToLeave.length > 0 and $scope.projectsToDelete.length > 0
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "delete-and-leave"
|
2014-09-01 13:05:51 -04:00
|
|
|
else if $scope.projectsToLeave.length == 0 and $scope.projectsToDelete.length > 0
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "delete"
|
2014-09-01 13:05:51 -04:00
|
|
|
else
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "leave"
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.delete = () ->
|
|
|
|
$modalInstance.close()
|
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
|
|
|
|
App.controller 'UploadProjectModalController', ($scope, $modalInstance, $timeout) ->
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
$scope.onComplete = (error, name, response) ->
|
|
|
|
if response.project_id?
|
2016-01-28 10:11:57 -05:00
|
|
|
window.location = '/project/' + response.project_id
|