org tree now adds children and leaves parents as ID's
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Aug 2005 16:00:34 +0000 (16:00 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Aug 2005 16:00:34 +0000 (16:00 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1704 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/OrgTree.js
Open-ILS/web/opac/common/js/opac_utils.js

index 0a51e00..a672baf 100644 (file)
@@ -14,14 +14,13 @@ for (var i in orgArraySearcher) {
        if (x.parent_ou() == null || x.parent_ou() == '') {
                globalOrgTree = x;
                continue;
-       } else {
-               x.parent_ou(orgArraySearcher[x.parent_ou()]);
-       }
-       if (!x.parent_ou().children()) 
-               x.parent_ou().children(new Array());
+       } 
 
-       x.parent_ou().children().push(x.id());
+       var parent = findOrgUnit(x.parent_ou());
+       if (!parent.children()) parent.children(new Array());
+       parent.children().push(x);
 }
+
 function _tree_killer () {
        for (var i in orgArraySearcher) {
                x=orgArraySearcher[i];
@@ -35,3 +34,5 @@ function _tree_killer () {
 }
 
 var globalOrgTypes = JSON2js("[/*--S aout--*/[null,null,null,null,0,0,0,1,\"Consortium\",\"Everywhere in PINES\"]/*--E aout--*/,/*--S aout--*/[null,null,null,null,0,0,1,2,\"System\",\"Local Library System\",1]/*--E aout--*/,/*--S aout--*/[null,null,null,null,1,1,2,3,\"Branch\",\"This Branch\",2]/*--E aout--*/,/*--S aout--*/[null,null,null,null,1,1,3,5,\"Bookmobile\",\"Your Bookmobile\",3]/*--E aout--*/,/*--S aout--*/[null,null,null,null,1,1,3,4,\"Sub-lib\",\"This Specialized Library\",3]/*--E aout--*/]");
+
+alert(js2JSON(globalOrgTree));
index 9ca852c..87d53ca 100644 (file)
@@ -169,6 +169,7 @@ function _appendParam( fieldVar, fieldName, overrideArgs, getFunc, string ) {
 }
 
 
+/*
 function EX(message) { this.init(message); }
 EX.prototype.init = function(message) { this.message = message; }
 EX.prototype.toString = function() { return "\n *** Exception Occured \n" + this.message; }  
@@ -176,6 +177,7 @@ EXCommunication.prototype              = new EX();
 EXCommunication.prototype.constructor  = EXCommunication;
 EXCommunication.baseClass              = EX.prototype.constructor;
 function EXCommunication(message) { this.init("EXCommunication: " + message); }                          
+*/
 
 /* ----------------------------------------------------------------------- */
 function cleanISBN(isbn) {
@@ -361,7 +363,7 @@ function buildOrgSelector() {
                        tree.add(node.id(), -1, node.name(), 
                                "javascript:orgSelect(" + node.id() + ");", node.name());
                else {
-                       tree.add(node.id(), node.parent_ou().id(), node.name(), 
+                       tree.add(node.id(), findOrgUnit(node.parent_ou()).id(), node.name(), 
                                "javascript:orgSelect(" + node.id() + ");", node.name());
                }
        }