diff --git a/services/web/app/views/project/editor/left-menu.jade b/services/web/app/views/project/editor/left-menu.jade index 9aa630cd3f..80d225d739 100644 --- a/services/web/app/views/project/editor/left-menu.jade +++ b/services/web/app/views/project/editor/left-menu.jade @@ -31,10 +31,17 @@ aside#left-menu.full-size( br | PDF - span(ng-controller="TemplatesController", ng-show="permissions.admin") - h4() Publish - ul.list-unstyled.nav() - li + span + h4 Actions + ul.list-unstyled.nav + li(ng-controller="CloneProjectController") + a( + href, + ng-click="openCloneProjectModal()" + ) + i.fa.fa-fw.fa-copy + |   Copy Project + li(ng-controller="TemplatesController", ng-show="permissions.admin") a(ng-click="openPublishTemplateModal()") i.fa.fa-external-link.fa-fw |   Publish as Template @@ -116,4 +123,31 @@ aside#left-menu.full-size( ng-show="ui.leftMenuShown", ng-click="ui.leftMenuShown = false" ng-cloak -) \ No newline at end of file +) + +script(type='text/ng-template', id='cloneProjectModalTemplate') + .modal-header + h3 Copy Project + .modal-body + form(name="cloneProjectForm", novalidate) + .form-group + label New Name + input.form-control( + type="text", + placeholder="New Project Name", + required, + ng-model="inputs.projectName", + on-enter="clone()", + focus-on="open" + ) + .modal-footer + button.btn.btn-default( + ng-disabled="state.inflight" + ng-click="cancel()" + ) Cancel + button.btn.btn-primary( + ng-disabled="cloneProjectForm.$invalid || state.inflight" + ng-click="clone()" + ) + span(ng-hide="state.inflight") Copy + span(ng-show="state.inflight") Copying... \ No newline at end of file diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index aedac82ec6..3961ef2289 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -11,6 +11,7 @@ define [ "ide/settings/index" "ide/share/index" "ide/chat/index" + "ide/clone/index" "ide/templates/index" "ide/directives/layout" "ide/services/ide" diff --git a/services/web/public/coffee/ide/clone/controllers/CloneProjectController.coffee b/services/web/public/coffee/ide/clone/controllers/CloneProjectController.coffee new file mode 100644 index 0000000000..020b018d61 --- /dev/null +++ b/services/web/public/coffee/ide/clone/controllers/CloneProjectController.coffee @@ -0,0 +1,9 @@ +define [ + "base" +], (App) -> + App.controller 'CloneProjectController', ($scope, $modal) -> + $scope.openCloneProjectModal = () -> + $modal.open { + templateUrl: "cloneProjectModalTemplate" + controller: "CloneProjectModalController" + } \ No newline at end of file diff --git a/services/web/public/coffee/ide/clone/controllers/CloneProjectModalController.coffee b/services/web/public/coffee/ide/clone/controllers/CloneProjectModalController.coffee new file mode 100644 index 0000000000..c8d5d3268c --- /dev/null +++ b/services/web/public/coffee/ide/clone/controllers/CloneProjectModalController.coffee @@ -0,0 +1,29 @@ +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) -> + console.log "DATA", data + #window.location = "/project/#{data.project_id}" + + $scope.cancel = () -> + $modalInstance.dismiss('cancel') \ No newline at end of file diff --git a/services/web/public/coffee/ide/clone/index.coffee b/services/web/public/coffee/ide/clone/index.coffee new file mode 100644 index 0000000000..e9c49b4766 --- /dev/null +++ b/services/web/public/coffee/ide/clone/index.coffee @@ -0,0 +1,4 @@ +define [ + "ide/clone/controllers/CloneProjectController" + "ide/clone/controllers/CloneProjectModalController" +] \ No newline at end of file diff --git a/services/web/public/coffee/main/project-list.coffee b/services/web/public/coffee/main/project-list.coffee index 656be90840..3b8a379226 100644 --- a/services/web/public/coffee/main/project-list.coffee +++ b/services/web/public/coffee/main/project-list.coffee @@ -493,7 +493,7 @@ define [ $modalInstance.opened.then () -> $timeout () -> $scope.$broadcast "open" - , 700 + , 200 $scope.create = () -> $modalInstance.close($scope.inputs.newTagName) @@ -508,7 +508,7 @@ define [ $modalInstance.opened.then () -> $timeout () -> $scope.$broadcast "open" - , 700 + , 200 $scope.rename = () -> $modalInstance.close($scope.inputs.projectName) @@ -525,7 +525,7 @@ define [ $modalInstance.opened.then () -> $timeout () -> $scope.$broadcast "open" - , 700 + , 200 $scope.clone = () -> $scope.state.inflight = true @@ -547,7 +547,7 @@ define [ $modalInstance.opened.then () -> $timeout () -> $scope.$broadcast "open" - , 700 + , 200 $scope.create = () -> $scope.state.inflight = true