Fix selection bugs

This commit is contained in:
James Allen 2014-06-24 17:24:29 +01:00
parent 2520651ef2
commit 7104f458f7
2 changed files with 5 additions and 2 deletions

View file

@ -62,11 +62,10 @@ define [
@_moveEntityInScope(entity, folder) @_moveEntityInScope(entity, folder)
selectEntity: (entity) -> selectEntity: (entity) ->
return if entity.selected # Don't get into a recursive event loop @selected_entity_id = entity.id # For reselecting after a reconnect
@ide.fileTreeManager.forEachEntity (entity) -> @ide.fileTreeManager.forEachEntity (entity) ->
entity.selected = false entity.selected = false
entity.selected = true entity.selected = true
@$scope.$emit "entity:selected", entity
findEntityById: (id) -> findEntityById: (id) ->
@_findEntityByIdInFolder @$scope.rootFolder, id @_findEntityByIdInFolder @$scope.rootFolder, id
@ -104,6 +103,7 @@ define [
id: rawFolder._id id: rawFolder._id
type: "folder" type: "folder"
children: [] children: []
selected: (rawFolder._id == @selected_entity_id)
} }
for doc in rawFolder.docs or [] for doc in rawFolder.docs or []
@ -111,6 +111,7 @@ define [
name: doc.name name: doc.name
id: doc._id id: doc._id
type: "doc" type: "doc"
selected: (doc._id == @selected_entity_id)
} }
for file in rawFolder.fileRefs or [] for file in rawFolder.fileRefs or []
@ -118,6 +119,7 @@ define [
name: file.name name: file.name
id: file._id id: file._id
type: "file" type: "file"
selected: (file._id == @selected_entity_id)
} }
for childFolder in rawFolder.folders or [] for childFolder in rawFolder.folders or []

View file

@ -4,6 +4,7 @@ define [
App.controller "FileTreeEntityController", ["$scope", "ide", "$modal", ($scope, ide, $modal) -> App.controller "FileTreeEntityController", ["$scope", "ide", "$modal", ($scope, ide, $modal) ->
$scope.select = () -> $scope.select = () ->
ide.fileTreeManager.selectEntity($scope.entity) ide.fileTreeManager.selectEntity($scope.entity)
$scope.$emit "entity:selected", $scope.entity
$scope.inputs = $scope.inputs =
name: $scope.entity.name name: $scope.entity.name