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)
|
2017-06-20 06:49:55 -04:00
|
|
|
.then () ->
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
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-06-20 06:49:55 -04:00
|
|
|
.then () ->
|
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()
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
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-06-20 11:27:05 -04:00
|
|
|
.then (response) ->
|
|
|
|
{ data } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close(data.project_id)
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
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"
|
2018-08-13 08:52:21 -04:00
|
|
|
$scope.projectsToArchive = projects.filter (project) ->
|
|
|
|
project.accessLevel == "owner" and !project.archived
|
2018-08-13 07:33:31 -04:00
|
|
|
|
2014-09-01 13:05:51 -04:00
|
|
|
if $scope.projectsToLeave.length > 0 and $scope.projectsToDelete.length > 0
|
2018-08-13 08:59:35 -04:00
|
|
|
if $scope.projectsToArchive.length > 0 and window.ExposedSettings.isOverleaf
|
|
|
|
$scope.action = "archive-and-leave"
|
|
|
|
else
|
|
|
|
$scope.action = "delete-and-leave"
|
2014-09-01 13:05:51 -04:00
|
|
|
else if $scope.projectsToLeave.length == 0 and $scope.projectsToDelete.length > 0
|
2018-08-13 08:52:21 -04:00
|
|
|
if $scope.projectsToArchive.length > 0 and window.ExposedSettings.isOverleaf
|
2018-08-13 07:33:31 -04:00
|
|
|
$scope.action = "archive"
|
|
|
|
else
|
|
|
|
$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
|
2017-11-27 08:46:08 -05:00
|
|
|
|
|
|
|
App.controller 'V1ImportModalController', ($scope, $modalInstance, project) ->
|
2017-11-28 06:31:31 -05:00
|
|
|
$scope.project = project
|
|
|
|
|
|
|
|
$scope.dismiss = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|