added function to return a flat list of org + descendants
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 May 2008 02:55:59 +0000 (02:55 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 May 2008 02:55:59 +0000 (02:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9714 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/fieldmapper/OrgUtils.js

index e01bbe8..e65dcb3 100644 (file)
@@ -185,6 +185,23 @@ if(!dojo._hasResource["fieldmapper.OrgUtils"]){
                return false;
        }
 
+    /** Given an org id, returns an array of org units including
+     * the org for the ID provided and all descendant orgs */
+    fieldmapper.aou.descendantNodeList = function(orgId) {
+        var list = [];
+        function addNode(node) {
+            if(!node) return;
+            list.push(node);
+            var children = node.children();
+            if(children) {
+                for(var i = 0; i < children.length; i++) 
+                    addNode(children[i]);
+            }
+        }
+        addNode(fieldmapper.aou.findOrgUnit(orgId));
+        return list;
+    }
+
        dojo.addOnUnload( function () {
                for (var i in fieldmapper.aou.OrgCache) {
                        x=fieldmapper.aou.OrgCache[i].treePtr;