From 3cbc3aa8f631ccce8c60f3c5e6a891ba2ef9a499 Mon Sep 17 00:00:00 2001 From: djfiander Date: Wed, 28 May 2008 23:39:46 +0000 Subject: [PATCH] Move buildPermFundSelector into Fund.js git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9722 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/User.js | 45 --------------------- Open-ILS/web/js/dojo/openils/acq/Fund.js | 46 ++++++++++++++++++++++ Open-ILS/web/js/dojo/openils/editors.js | 4 +- .../templates/oils/default/common/jubgrid.html | 2 +- 4 files changed, 50 insertions(+), 47 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/User.js b/Open-ILS/web/js/dojo/openils/User.js index a277cd9120..66013c563d 100644 --- a/Open-ILS/web/js/dojo/openils/User.js +++ b/Open-ILS/web/js/dojo/openils/User.js @@ -43,7 +43,6 @@ if(!dojo._hasResource["openils.User"]) { this.location = kwargs.location; this.authcookie = kwargs.authcookie || openils.User.authcookie; this.orgCache = {perm: null, store: null}; - this.fundCache = []; if (this.id && this.authtoken) this.user = this.getById( this.id ); else if (this.authtoken) this.getBySession(); @@ -258,50 +257,6 @@ if(!dojo._hasResource["openils.User"]) { } }, - /** - * Sets the store for an existing openils.widget.FundFilteringSelect - * using the funds where the user has the requested permission. - * @param perm The permission to check - * @param selector The pre-created dijit.form.FilteringSelect object. - */ - buildPermFundSelector : function(perm, selector) { - var _u = this; - - dojo.require('dojo.data.ItemFileReadStore'); - - function hookupStore(store) { - selector.store = store; - selector.startup(); - } - - function buildPicker(r) { - var msg; - var fundList = []; - while (msg = r.recv()) { - var fund = msg.content(); - fundList.push(fund); - } - - var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData(fundList)}); - - hookupStore(store); - _u.fundCache[perm] = store; - } - - if (this.fundCache[perm]) { - hookupStore(this.fundCache[perm]); - } else { - fieldmapper.standardRequest( - ['open-ils.acq', 'open-ils.acq.fund.org.retrieve'], - { params: [this.authtoken, null, {flesh_summary:1, limit_perm:perm}], - oncomplete: buildPicker, - async: true - } - ) - } - } - - }); openils.User.user = null; diff --git a/Open-ILS/web/js/dojo/openils/acq/Fund.js b/Open-ILS/web/js/dojo/openils/acq/Fund.js index 60bb5807d9..0c609f1710 100644 --- a/Open-ILS/web/js/dojo/openils/acq/Fund.js +++ b/Open-ILS/web/js/dojo/openils/acq/Fund.js @@ -161,4 +161,50 @@ openils.acq.Fund.nameMapping = function(oncomplete) { openils.acq.Fund.createStore(buildMap); } }; + +/** + * Sets the store for an existing openils.widget.FundFilteringSelect + * using the funds where the user has the requested permission. + * @param perm The permission to check + * @param selector The pre-created dijit.form.FilteringSelect object. + */ + +openils.acq.Fund.storeCache = []; + +openils.acq.Fund.buildPermFundSelector = function(perm, selector) { + dojo.require('dojo.data.ItemFileReadStore'); + + function hookupStore(store) { + selector.store = store; + selector.startup(); + } + + function buildPicker(r) { + var msg; + var fundList = []; + while (msg = r.recv()) { + var fund = msg.content(); + fundList.push(fund); + } + + var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData(fundList)}); + + hookupStore(store); + openils.acq.Fund.storeCache[perm] = store; + } + + if (openils.acq.Fund.storeCache[perm]) { + hookupStore(openils.acq.Fund.storeCache[perm]); + } else { + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.fund.org.retrieve'], + { params: [openils.User.authtoken, null, + {flesh_summary:1, limit_perm:perm}], + oncomplete: buildPicker, + async: true + } + ) + } +} + } diff --git a/Open-ILS/web/js/dojo/openils/editors.js b/Open-ILS/web/js/dojo/openils/editors.js index b0db5cdc8a..a0b880ef66 100644 --- a/Open-ILS/web/js/dojo/openils/editors.js +++ b/Open-ILS/web/js/dojo/openils/editors.js @@ -10,6 +10,8 @@ dojo.require('dijit.form.FilteringSelect'); dojo.require("openils.widget.FundSelector"); dojo.require("openils.widget.OrgUnitFilteringSelect"); +dojo.require("openils.acq.Fund"); + dojo.declare("openils.editors.NumberSpinner", dojox.grid.editors.Dijit, { editorClass: "dijit.form.NumberSpinner", @@ -32,7 +34,7 @@ dojo.declare('openils.editors.FundSelectEditor', dojox.grid.editors.Dijit, { editorClass: "openils.widget.FundSelector", createEditor: function(inNode, inDatum, inRowIndex) { var editor = new this.editorClass(this.getEditorProps(inDatum), inNode); - globalUser.buildPermFundSelector(this.cell.perm || this.perm, + openils.acq.Fund.buildPermFundSelector(this.cell.perm || this.perm, editor); return editor; }, diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html index c5b47bdbd0..edda1634f5 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html @@ -93,7 +93,7 @@ pointing to the JUB model (and store) that you have created. execute="createLID(arguments[0]);"> -- 2.11.0