Org unit custom tree sort repairs
authorBill Erickson <berick@esilibrary.com>
Tue, 3 Apr 2012 19:14:35 +0000 (15:14 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 9 Apr 2012 14:22:17 +0000 (10:22 -0400)
Repairs a problem with detecting and storing the sort order of sibling
nodes within custom trees.  The original problem was the result of
comparing parent nodes for non-siblings because of a depth-first tree
traversal.  Now we process siblings in level-order before processing
child nodes.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js

index 695a9c4..909de62 100644 (file)
@@ -169,9 +169,12 @@ function applyChanges2() {
     var prevTn;
     var progress = 0;
 
+    // flatten child nodes into a level-order (by parent) list
+    var nodeList = [magicTree.rootNode];
     function flatten(node) {
-        nodeList.push(node);
-        dojo.forEach(node.getChildren(), flatten);
+        var kids = node.getChildren();
+        nodeList = nodeList.concat(kids);
+        dojo.forEach(kids, flatten);
     }
     flatten(magicTree.rootNode);