Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions angular-tree-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex

$scope.options = $scope.options || {};
ensureDefault($scope.options, "multiSelection", false);
ensureDefault($scope.options, "recursiveSelection", false);
ensureDefault($scope.options, "nodeChildren", "children");
ensureDefault($scope.options, "dirSelectable", "true");
ensureDefault($scope.options, "injectClasses", {});
Expand Down Expand Up @@ -176,7 +177,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
}
};

$scope.selectNodeLabel = function( selectedNode){
$scope.selectNodeLabel = function( selectedNode, value){
var transcludedScope = this;
if(!$scope.options.isLeaf(selectedNode) && (!$scope.options.dirSelectable || !$scope.options.isSelectable(selectedNode))) {
// Branch node is not selectable, expand
Expand All @@ -196,12 +197,20 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
break;
}
}
if (pos === -1) {
if (pos === -1 && (value === undefined || value === true)) {
$scope.selectedNodes.push(selectedNode);
selected = true;
} else {
} else if (pos !== -1 && value === true) {
selected = true;
} else if (pos !== -1 && (value === undefined || value === false)) {
$scope.selectedNodes.splice(pos, 1);
}
if($scope.options.recursiveSelection) {
var children = selectedNode[$scope.options.nodeChildren] || [];
for(var i=0; i<children.length; i++) {
$scope.selectNodeLabel(children[i], value || selected);
}
}
} else {
if (!$scope.options.equality(selectedNode, $scope.selectedNode)) {
$scope.selectedNode = selectedNode;
Expand Down