FileTreeEntityController.coffee 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. define [
  2. "base"
  3. ], (App) ->
  4. App.controller "FileTreeEntityController", ["$scope", "ide", "$modal", ($scope, ide, $modal) ->
  5. $scope.select = () ->
  6. ide.fileTreeManager.forEachEntity (entity) ->
  7. entity.selected = false
  8. $scope.entity.selected = true
  9. $scope.inputs =
  10. name: $scope.entity.name
  11. $scope.startRenaming = () ->
  12. $scope.entity.renaming = true
  13. $scope.finishRenaming = () ->
  14. delete $scope.entity.renaming
  15. ide.fileTreeManager.renameEntity($scope.entity, $scope.inputs.name)
  16. $scope.$on "rename:selected", () ->
  17. $scope.startRenaming() if $scope.entity.selected
  18. $scope.openDeleteModal = () ->
  19. $modal.open(
  20. templateUrl: "deleteEntityModalTemplate"
  21. controller: "DeleteEntityModalController"
  22. scope: $scope
  23. )
  24. $scope.$on "delete:selected", () ->
  25. $scope.openDeleteModal() if $scope.entity.selected
  26. ]
  27. App.controller "DeleteEntityModalController", [
  28. "$scope", "ide", "$modalInstance",
  29. ($scope, ide, $modalInstance) ->
  30. $scope.state =
  31. inflight: false
  32. $scope.delete = () ->
  33. $scope.state.inflight = true
  34. ide.fileTreeManager
  35. .deleteEntity($scope.entity)
  36. .success () ->
  37. $scope.state.inflight = false
  38. $modalInstance.close()
  39. $scope.cancel = () ->
  40. $modalInstance.dismiss('cancel')
  41. ]