[open-ils-commits] r13848 - trunk/Open-ILS/web/js/ui/default/acq/financial (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Aug 17 12:14:54 EDT 2009
Author: erickson
Date: 2009-08-17 12:14:51 -0400 (Mon, 17 Aug 2009)
New Revision: 13848
Modified:
trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
Log:
using new fund year list to populate year selector
Modified: trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js 2009-08-17 16:12:49 UTC (rev 13847)
+++ trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js 2009-08-17 16:14:51 UTC (rev 13848)
@@ -25,13 +25,15 @@
return 0;
}
+function initPage() {
+ loadYearSelector();
+ loadFundGrid();
+}
+
function loadFundGrid(year) {
- var yearStore = {identifier:'year', name:'year', items:[]};
- var yearsAdded = {}; /* don't duplicate the years in the selector */
+
lfGrid.resetStore();
-
- if(!year) year = new Date().getFullYear().toString();
-
+ year = year || new Date().getFullYear().toString();
lfGrid.dataLoader = function() { loadFundGrid(year); };
fieldmapper.standardRequest(
@@ -52,29 +54,40 @@
if(lf = openils.Util.readResponse(r)) {
openils.acq.Fund.cache[lf.id()] = lf;
lfGrid.store.newItem(acqf.toStoreItem(lf));
- var year = lf.year();
- if(!(year in yearsAdded)) {
- yearStore.items.push({year:year});
- yearsAdded[year] = 1;
- }
}
},
oncomplete : function(r) {
+ lfGrid.hideLoadProgressIndicator();
+ }
+ }
+ );
+}
+
+function loadYearSelector() {
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.fund.org.years.retrieve'],
+ { async : true,
+ params : [openils.User.authtoken],
+ oncomplete : function(r) {
+
+ var yearList = openils.Util.readResponse(r);
+ if(!yearList) return;
+ yearList = yearList.map(function(year){return {year:year+''};}); // dojo wants strings
+
+ var yearStore = {identifier:'year', name:'year', items:yearList};
yearStore.items = yearStore.items.sort().reverse();
fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
- var today = new Date().getFullYear().toString();
- if(today in yearsAdded)
- fundFilterYearSelect.setValue(today);
+ // default to this year
+ fundFilterYearSelect.setValue(new Date().getFullYear().toString());
- lfGrid.hideLoadProgressIndicator();
-
dojo.connect(
fundFilterYearSelect,
'onChange',
function() {
- loadFundGrid(fundFilterYearSelect.getValue());
+ loadFundGrid(fundFilterYearSelect.attr('value'));
}
);
}
@@ -82,6 +95,5 @@
);
}
+openils.Util.addOnLoad(initPage);
-openils.Util.addOnLoad(loadFundGrid);
-
More information about the open-ils-commits
mailing list