Move buildPermFundSelector into Fund.js
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 May 2008 23:39:46 +0000 (23:39 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 May 2008 23:39:46 +0000 (23:39 +0000)
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
Open-ILS/web/js/dojo/openils/acq/Fund.js
Open-ILS/web/js/dojo/openils/editors.js
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html

index a277cd9..66013c5 100644 (file)
@@ -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;
index 60bb580..0c609f1 100644 (file)
@@ -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
+            }
+       )
+    }
+}
+
 }
index b0db5cd..a0b880e 100644 (file)
@@ -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;
     },
index c5b47bd..edda163 100644 (file)
@@ -93,7 +93,7 @@ pointing to the JUB model (and store) that you have created.
                     execute="createLID(arguments[0]);">
                    <script type='dojo/connect' event='onOpen'>
                        globalUser.buildPermOrgSelector('MANAGE_FUND', copyOwnerSelect);
-                       globalUser.buildPermFundSelector('MANAGE_FUND', acqlidFund);
+                       openils.acq.Fund.buildPermFundSelector('MANAGE_FUND', acqlidFund);
                    </script>
                    <table class="dijitTooltipTable">
                        <tr>