overleaf/services/web/public/coffee/ide/file-tree/controllers/FileTreeFolderController.coffee

57 lines
1.7 KiB
CoffeeScript
Raw Normal View History

2014-07-08 11:02:26 +00:00
define [
"base"
], (App) ->
App.controller "FileTreeFolderController", ($scope, ide, $modal, localStorage) ->
$scope.expanded = localStorage("folder.#{$scope.entity.id}.expanded") or false
2014-07-08 11:02:26 +00:00
$scope.toggleExpanded = () ->
$scope.expanded = !$scope.expanded
localStorage("folder.#{$scope.entity.id}.expanded", $scope.expanded)
2014-07-08 11:02:26 +00:00
$scope.onDrop = (events, ui) ->
if ide.fileTreeManager.multiSelectedCount()
entities = ide.fileTreeManager.getMultiSelectedEntityChildNodes()
else
entities = [$(ui.draggable).scope().entity]
for dropped_entity in entities
ide.fileTreeManager.moveEntity(dropped_entity, $scope.entity)
$scope.$digest()
# clear highlight explicitly
$('.file-tree-inner .droppable-hover').removeClass('droppable-hover')
2014-07-08 11:02:26 +00:00
$scope.orderByFoldersFirst = (entity) ->
# We need this here as well as in FileTreeController
# since the file-entity diretive creates a new scope
# that doesn't inherit from previous scopes.
return '0' if entity?.type == "folder"
2014-07-08 11:02:26 +00:00
return '1'
$scope.openNewDocModal = () ->
$modal.open(
templateUrl: "newDocModalTemplate"
controller: "NewDocModalController"
resolve: {
parent_folder: () -> $scope.entity
}
)
$scope.openNewFolderModal = () ->
$modal.open(
templateUrl: "newFolderModalTemplate"
controller: "NewFolderModalController"
resolve: {
parent_folder: () -> $scope.entity
}
)
$scope.openUploadFileModal = () ->
$scope.project_id = ide.project_id
$modal.open(
templateUrl: "uploadFileModalTemplate"
controller: "UploadFileModalController"
scope: $scope
resolve: {
parent_folder: () -> $scope.entity
}
)