2014-07-17 13:04:21 +00:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.controller 'CloneProjectModalController', ($scope, $modalInstance, $timeout, $http, ide) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: ide.$scope.project.name + " (Copy)"
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
cloneProject = (cloneName) ->
|
|
|
|
$http.post("/project/#{ide.$scope.project._id}/clone", {
|
|
|
|
_csrf: window.csrfToken
|
|
|
|
projectName: cloneName
|
|
|
|
})
|
|
|
|
|
|
|
|
$scope.clone = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
cloneProject($scope.inputs.projectName)
|
|
|
|
.then (data) ->
|
2014-07-31 11:39:23 +00:00
|
|
|
window.location = "/project/#{data.data.project_id}"
|
2014-07-17 13:04:21 +00:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|