FileTreeEntityController.coffee 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. name = $scope.inputs.name
  14. if !name? or name.length == 0
  15. return
  16. delete $scope.entity.renaming
  17. ide.fileTreeManager.renameEntity($scope.entity, name)
  18. $scope.$on "rename:selected", () ->
  19. $scope.startRenaming() if $scope.entity.selected
  20. $scope.openDeleteModal = () ->
  21. $modal.open(
  22. templateUrl: "deleteEntityModalTemplate"
  23. controller: "DeleteEntityModalController"
  24. scope: $scope
  25. )
  26. $scope.$on "delete:selected", () ->
  27. $scope.openDeleteModal() if $scope.entity.selected
  28. ]
  29. App.controller "DeleteEntityModalController", [
  30. "$scope", "ide", "$modalInstance",
  31. ($scope, ide, $modalInstance) ->
  32. $scope.state =
  33. inflight: false
  34. $scope.delete = () ->
  35. $scope.state.inflight = true
  36. ide.fileTreeManager
  37. .deleteEntity($scope.entity)
  38. .success () ->
  39. $scope.state.inflight = false
  40. $modalInstance.close()
  41. $scope.cancel = () ->
  42. $modalInstance.dismiss('cancel')
  43. ]