From: djfiander Date: Sun, 25 May 2008 13:46:38 +0000 (+0000) Subject: Cache OrgUnit store we create in BuildPermOrgSelector, so that we X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1eda6017a01bb8241e83af7ff1689c21164b3bca;p=Evergreen.git 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. git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9702 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/User.js b/Open-ILS/web/js/dojo/openils/User.js index 875c695ace..57fdcccd1c 100644 --- a/Open-ILS/web/js/dojo/openils/User.js +++ b/Open-ILS/web/js/dojo/openils/User.js @@ -42,6 +42,8 @@ if(!dojo._hasResource["openils.User"]) { 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 @@ if(!dojo._hasResource["openils.User"]) { 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 + } + ) + } } });