added a synchronous call to fetch the fund for the allocation list.. will make async.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 11 Apr 2008 21:52:49 +0000 (21:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 11 Apr 2008 21:52:49 +0000 (21:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9317 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html

index e8eca7f..ce34729 100644 (file)
     dojo.require("dijit.form.CurrencyTextBox");
     dojo.require('openils.acq.FundingSource');
     
+    var ses = new OpenSRF.ClientSession('open-ils.acq');
     var fundingSourceID = ${c.oils.acq.funding_source_id};
     var fundingSource = null;
+    var fundCache = {};
 
     /** creates a new funding_source_credit from the dialog ----- */
     function applyFSCredit(fields) {
 
     /** fetch the fleshed funding source ----- */
     function loadFS() {
-        var ses = new OpenSRF.ClientSession('open-ils.acq');
         var req = ses.request(
-            'open-ils.acq.funding_source.retrieve',
-            oilsAuthtoken, 
-            fundingSourceID, 
+            'open-ils.acq.funding_source.retrieve', oilsAuthtoken, fundingSourceID, 
             {flesh_summary:1, flesh_credits:1,flesh_allocations:1}
         );
 
             case 4: return new String(fundingSource.summary().allocation_total);
         }
     }
+    
+    function getFund(rowIndex) {
+        /** synchronous version ... XXX need to refactor this to be async */
+        data = fsAllocationGrid.model.getRow(rowIndex);
+        if(!data) return;
+        var fundId = data.fund;
+        if(!fundCache[fundId]) {
+            req = ses.request('open-ils.acq.fund.retrieve', oilsAuthtoken, fundId);
+            req.timeout = 10;
+            req.send();
+            fundCache[fundId] = req.recv().content();
+        }
+        return fundCache[fundId].name()
+    }
 
     /** builds the credits grid ----- */
     function loadFSGrid() {
                 var fsAllocationGridLayout = [{
                     cells : [[
                         {name: '${_("ID")}', field: 'id'},
-                        {name: '${_("Fund")}', field: "fund"}, 
+                        {name: '${_("Fund")}', field: "fund", get:getFund}, 
                         {name: '${_("Amount")}', field: "amount"}, 
                         {name: '${_("Percent")}', field: "percent"}, 
                         {name: '${_("Allocated By")}', field: "allocator"},