programmatic selection of tree node still not working
authorJason Etheridge <jason@esilibrary.com>
Fri, 10 Jun 2016 18:22:45 +0000 (14:22 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 19:34:22 +0000 (15:34 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/web/js/ui/default/staff/admin/actor/org_unit/app.js

index 323288e..6d2ebc8 100644 (file)
@@ -35,9 +35,20 @@ function($scope , $q , $routeParams , $window , egCore , egOrg  ) {
 
     // the org tree
 
-    function init(n) {
+    function init(id) {
         $scope.treedata = [ egCore.idl.toHash( egOrg.tree() ) ];
-        $scope.selected = $scope.treedata[0]; // FIXME -- why no work?
+        function find_org(tree,id) {
+            if (tree.id==id) {
+                return tree;
+            }
+            for (var i in tree.children) {
+                var child = tree.children[i];
+                ou = find_org( child, id );
+                if (ou) { return ou; }
+            }
+            return null;
+        }
+        $scope.selected = find_org($scope.treedata,id) || $scope.treedata[0]; // FIXME -- why no work?
         $scope.expandedNodes = [ $scope.treedata[0], $scope.selected ];
     }
     init(1);