});
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;
openils.acq.Fund.cache[src.id()] = src;
items.push(src);
}
+ openils.acq.Fund._cachecomplete = true;
onComplete(acqf.toStoreData(items));
}
}
);
};
-}
+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);
+ }
+};
+}
dojo.require("dojox.grid.editors");
+ dojo.require('openils.acq.Fund');
dojo.require('fieldmapper.Fieldmapper');
dojo.require('fieldmapper.dojoData');
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;
});
});
}