[open-ils-commits] r9644 - in branches/acq-experiment/Open-ILS/web/js/dojo/openils: acq widget

svn at svn.open-ils.org svn at svn.open-ils.org
Tue May 20 15:09:20 EDT 2008


Author: djfiander
Date: 2008-05-20 15:09:16 -0400 (Tue, 20 May 2008)
New Revision: 9644

Modified:
   branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Fund.js
   branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js
Log:
Eliminate duplicate call to get list of Funds

Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Fund.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Fund.js	2008-05-19 21:09:33 UTC (rev 9643)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Fund.js	2008-05-20 19:09:16 UTC (rev 9644)
@@ -26,9 +26,10 @@
 });
 
 openils.acq.Fund.cache = {};
+openils.acq.Fund._cachecomplete = false;
 
 openils.acq.Fund.createStore = function(onComplete, limitPerm) {
-    /** Fetches the list of funding_sources and builds a grid from them */
+    /** Fetches the list of funds and builds a grid from them */
 
     function mkStore(r) {
         var msg;
@@ -38,6 +39,7 @@
             openils.acq.Fund.cache[src.id()] = src;
             items.push(src);
         }
+	openils.acq.Fund._cachecomplete = true;
         onComplete(acqf.toStoreData(items));
     }
 
@@ -140,5 +142,22 @@
         }
     );
 };
+
+openils.acq.Fund.nameMapping = function(oncomplete) {
+    var ids = [];
+    var names = [];
+    var buildMap = function() {
+	for (var i in openils.acq.Fund.cache) {
+	    ids.push(i.id());
+	    names.push(i.name());
+	    oncomplete(ids, names);
+	}
+    };
+
+    if (openils.acq.Fund._cachecomplete) {
+	buildMap(oncomplete);
+    } else {
+	openils.acq.Fund.createStore(buildMap);
+    }
+};
 }
-

Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js	2008-05-19 21:09:33 UTC (rev 9643)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js	2008-05-20 19:09:16 UTC (rev 9644)
@@ -4,6 +4,7 @@
 
     dojo.require("dojox.grid.editors");
 
+    dojo.require('openils.acq.Fund');
     dojo.require('fieldmapper.Fieldmapper');
     dojo.require('fieldmapper.dojoData');
 
@@ -25,21 +26,10 @@
 
     dojo.addOnLoad(
 	function() {
-	    fieldmapper.standardRequest(
-		['open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
-		{
-		    async: true,
-		    params: [openils.User.authtoken, null, {flesh_summary:1}],
-		    oncomplete: function (r) {
-			var msg;
-			
-			while (msg = r.recv()) {
-			    var f = msg.content();
-			    console.dir(f)
-			    openils.widget.FundSelector.fundNames.push(f.name());
-			    openils.widget.FundSelector.fundCodes.push(f.id());
-			}
-		    }
+	    openils.acq.Fund.nameMapping(
+		function(ids, names) {
+		    openils.widget.FundSelector.fundCodes = ids;
+		    openils.widget.FundSelector.fundNames = names;
 		});
 	});
 }



More information about the open-ils-commits mailing list