[open-ils-commits] r9730 - trunk/Open-ILS/web/js/dojo/openils

svn at svn.open-ils.org svn at svn.open-ils.org
Thu May 29 18:23:35 EDT 2008


Author: erickson
Date: 2008-05-29 18:23:31 -0400 (Thu, 29 May 2008)
New Revision: 9730

Modified:
   trunk/Open-ILS/web/js/dojo/openils/User.js
Log:
adding Davids org perm store caching with some slight modification.  using existing perm_org_set function instead of manually invoking

Modified: trunk/Open-ILS/web/js/dojo/openils/User.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/User.js	2008-05-29 15:19:35 UTC (rev 9729)
+++ trunk/Open-ILS/web/js/dojo/openils/User.js	2008-05-29 22:23:31 UTC (rev 9730)
@@ -42,6 +42,7 @@
             this.login_type = kwargs.login_type;
             this.location = kwargs.location;
             this.authcookie = kwargs.authcookie || openils.User.authcookie;
+            this.permOrgStoreCache = {}; /* permName => permOrgUnitStore map */
 
             if (this.id && this.authtoken) this.user = this.getById( this.id );
             else if (this.authtoken) this.getBySession();
@@ -169,17 +170,16 @@
          * has the given permission.
          */
         getPermOrgList : function(perm, onload) {
-    
-            var req = OpenSRF.CachedClientSession('open-ils.actor').request(
-                'open-ils.actor.user.work_perm.highest_org_set',
-                this.authtoken, perm);
-    
-            req.oncomplete = function(r) {
-                org_list = r.recv().content();
-                onload(org_list);
-            }
-    
-            req.send();
+            fieldmapper.standardRequest(
+                ['open-ils.actor', 'open-ils.actor.user.work_perm.highest_org_set'],
+                {   async: true,
+                    params: [this.authtoken, perm],
+                    oncomplete: function(r) {
+                        org_list = r.recv().content();
+                        onload(org_list);
+                    }
+                }
+            );
         },
     
         /**
@@ -229,29 +229,28 @@
     
             dojo.require('dojo.data.ItemFileReadStore');
 
-            function buildTreePicker(r) {
-                var orgList = r.recv().content();
-                var orgNodeList = [];
+            function hookupStore(store) {
+                selector.store = store;
+                selector.startup();
+                selector.setValue(_u.user.ws_ou());
+            }
 
+            function buildTreePicker(orgList) {
+                var orgNodeList = [];
                 for(var i = 0; i < orgList.length; i++) 
                     orgNodeList = orgNodeList.concat(
                         fieldmapper.aou.descendantNodeList(orgList[i]));
 
                 var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgNodeList)});
-                selector.store = store;
-                selector.startup();
-                selector.setValue(_u.user.ws_ou());
+                hookupStore(store);
+                _u.permOrgStoreCache[perm] = store;
             }
     
-            fieldmapper.standardRequest(
-                ['open-ils.actor', 'open-ils.actor.user.work_perm.highest_org_set'],
-                {   params: [this.authtoken, perm],
-                    oncomplete: buildTreePicker,
-                    async: true
-                }
-            )
+	        if (_u.permOrgStoreCache[perm])
+		        hookupStore(_u.permOrgStoreCache[perm]);
+	        else
+                _u.getPermOrgList(perm, buildTreePicker);
         }
-
     });
 
 	openils.User.user = null;



More information about the open-ils-commits mailing list