Stop being Dan's problem
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 May 2008 02:20:41 +0000 (02:20 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 May 2008 02:20:41 +0000 (02:20 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9684 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index e906faa..e01bbe8 100644 (file)
@@ -24,6 +24,7 @@ if(!dojo._hasResource["fieldmapper.OrgUtils"]){
        dojo.require("fieldmapper.OrgTree", true);
        dojo.require("fieldmapper.OrgLasso", true);
 
+       fieldmapper.aou.slim_ok = true;
        fieldmapper.aou.globalOrgTree = {};
        fieldmapper.aou.OrgCache = {};
        fieldmapper.aou.OrgCacheSN = {};
@@ -45,12 +46,14 @@ if(!dojo._hasResource["fieldmapper.OrgUtils"]){
        }
 
        fieldmapper.aou.LoadOrg = function (id, slim_ok) {
+               if (slim_ok == null) slim_ok = fieldmapper.aou.slim_ok;
                var slim_o = fieldmapper.aou.OrgCache[id];
 
                if (slim_o && (slim_ok || slim_o.loaded))
                        return fieldmapper.aou.OrgCache[id].org;
 
                var o = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_unit.retrieve'],[null,id]);
+               o.children = fieldmapper.aou.OrgCache[o.id()].children;
                fieldmapper.aou.OrgCache[o.id()] = { loaded : true, org : o };
                return o;
        }
@@ -126,21 +129,25 @@ if(!dojo._hasResource["fieldmapper.OrgUtils"]){
                return null;
        }
 
-       fieldmapper.aou.findOrgUnitSN = function (sn) {
+       fieldmapper.aou.findOrgUnitSN = function (sn, slim_ok) {
+               if (slim_ok == null) slim_ok = fieldmapper.aou.slim_ok;
                var org = fieldmapper.aou.OrgCacheSN[sn];
                if (!org) {
                        for (var i in fieldmapper.aou.OrgCache) {
                                var o = fieldmapper.aou.OrgCache[i];
-                               if (o.loaded && o.org.shortname() == sn) {
+                               if (o.org.shortname() == sn) {
                                        fieldmapper.aou.OrgCacheSN[o.org.shortname()] = o;
-                                       return o.org;
+                                       org = o;
                                }
                        }
 
-                       org = fieldmapper.standardRequest(fieldmapper.OpenSRF.methods.FETCH_ORG_BY_SHORTNAME, sn);
+                       if (!slim_ok && !fieldmapper.aou.OrgCache[org.id()].loaded) {
+                               org = fieldmapper.standardRequest(fieldmapper.OpenSRF.methods.FETCH_ORG_BY_SHORTNAME, sn);
 
-                       fieldmapper.aou.OrgCache[org.id()] = { loaded : true, org : org };
-                       fieldmapper.aou.OrgCacheSN[org.shortname()] = { loaded : true, org : org };
+                               org.children = fieldmapper.aou.OrgCache[org.id()].children;
+                               fieldmapper.aou.OrgCache[org.id()] = { loaded : true, org : org };
+                               fieldmapper.aou.OrgCacheSN[org.shortname()] = { loaded : true, org : org };
+                       }
 
                }
 
index 96bce5d..a0ab494 100644 (file)
@@ -42,7 +42,7 @@ if(!dojo._hasResource['fieldmapper.dojoData']){
                if (!list) list = {};
 
                // a sane default
-               if (!params.identifier) params.identifier = fieldmapper[this.classname].Identifier;
+               if (!params.identifier) params.identifier = this.Identifier;
                if (!label) label = params.label;
                if (!label) label = params.identifier;
 
@@ -96,17 +96,17 @@ if(!dojo._hasResource['fieldmapper.dojoData']){
 
        fieldmapper.aou.toStoreData = function (list, label) {
                if (!label) label = 'shortname';
-               return _toStoreData(list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
+               return _toStoreData.call(this, list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
        }
 
        fieldmapper.aout.toStoreData = function (list, label) {
                if (!label) label = 'name';
-               return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
+               return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
        }
 
        fieldmapper.pgt.toStoreData = function (list, label) {
                if (!label) label = 'name';
-               return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
+               return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
        }
 
        /*