[open-ils-commits] r9702 - branches/acq-experiment/Open-ILS/web/js/dojo/openils

svn at svn.open-ils.org svn at svn.open-ils.org
Sun May 25 09:46:39 EDT 2008


Author: djfiander
Date: 2008-05-25 09:46:38 -0400 (Sun, 25 May 2008)
New Revision: 9702

Modified:
   branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
Log:
Cache OrgUnit store we create in BuildPermOrgSelector, so that we
don't have to refetch the list of OrgUnits if we want to create
multiple funds at one time.


Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js	2008-05-25 12:58:57 UTC (rev 9701)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js	2008-05-25 13:46:38 UTC (rev 9702)
@@ -42,6 +42,8 @@
             this.login_type = kwargs.login_type;
             this.location = kwargs.location;
             this.authcookie = kwargs.authcookie || openils.User.authcookie;
+	    this.orgCache = {perm: null, store: null};
+	    this.fundStore = null;
 
             if (this.id && this.authtoken) this.user = this.getById( this.id );
             else if (this.authtoken) this.getBySession();
@@ -229,21 +231,31 @@
     
             dojo.require('dojo.data.ItemFileReadStore');
 
+	    function hookupStore(store) {
+		selector.store = store;
+                selector.startup();
+                selector.setValue(_u.user.ws_ou());
+	    }
+
             function buildTreePicker(r) {
                 var orgList = r.recv().content();
                 var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)});
-                selector.store = store;
-                selector.startup();
-                selector.setValue(_u.user.ws_ou());
+		hookupStore(store);
+		_u.orgCache.perm = perm;
+		_u.orgCache.orgStore = store;
             }
     
-            fieldmapper.standardRequest(
-                ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
-                {   params: [this.authtoken, perm],
-                    oncomplete: buildTreePicker,
-                    async: true
-                }
-            )
+	    if (this.orgCache.orgStore && (perm == this.orgCache.perm)) {
+		hookupStore(this.orgCache.orgStore);
+	    } else {
+		fieldmapper.standardRequest(
+                    ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
+                    {   params: [this.authtoken, perm],
+			oncomplete: buildTreePicker,
+			async: true
+                    }
+		)
+	    }
         }
 
     });



More information about the open-ils-commits mailing list