attempting to remove a big leak
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 Jul 2006 00:27:01 +0000 (00:27 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 Jul 2006 00:27:01 +0000 (00:27 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5053 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/backend/circ/circ_lib.js
Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm

index 72ad052..3501f81 100644 (file)
@@ -48,7 +48,8 @@ var groupList         = {};
 var groupIDList        = {};
 flattenGroupTree(groupTree);
 
-
+/* copy the org list into some other useful data structures */
+var orgList            = environment.orgList;
 
 
 
@@ -157,8 +158,27 @@ function getMARCItemType() {
        return (marcXMLDoc) ? extractFixedField(marcXMLDoc, 'Type') : "";
 }
 
+function __is_org_descendant( parent, child ) {
+       while( child = grep( function(x){ x.id() == child.parent_ou() }, orgList ) ) {
+               if (child[0].id() == parent.id()) return true;
+       }
+       return false;
+}
 
 function isOrgDescendent( parentName, childId ) {
+       var parent = grep( function(x){ x.shortname() == parentName }, orgList );
+       var child = grep( function(x){ x.id() == childId }, orgList );
+
+       if (parent) parent = parent[0];
+       if (child) child = child[0];
+
+       if (!child || !parent) return false;
+       if (child.id() == parent.id()) return true;
+
+       return __is_org_descendant( parent, child );
+}
+
+function old_isOrgDescendent( parentName, childId ) {
        var key = scratchKey();
        __OILS_FUNC_isOrgDescendent(scratchPad(key), parentName, childId);
        var val = getScratch(key);
index 3019657..28b0d9e 100644 (file)
@@ -85,9 +85,24 @@ sub build_runner {
 
        $runner->insert("$evt.$_", $ctx->{_direct}->{$_}) for keys %{$ctx->{_direct}};
 
-       $ctx->{runner} = $runner;
+       if(!$ORG_TREE) {
+               $ORG_TREE = $editor->search_actor_org_unit(
+                       [
+                               {"parent_ou" => undef },
+                               {
+                                       flesh                           => 2,
+                                       flesh_fields    => { aou =>  ['children'] },
+                                       order_by                        => { aou => 'name'}
+                               }
+                       ]
+               )->[0];
+               flatten_org_tree($ORG_TREE);
+       }
+       #insert_org_methods( $editor, $ctx );
 
-       insert_org_methods( $editor, $ctx );
+       $runner->insert( "$evt.orgList", $ORG_TREE, 1 );
+
+       $ctx->{runner} = $runner;
 
        return $runner;
 }