FileTreeEntityController.coffee 1.3 KB

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