[open-ils-commits] r11501 - trunk/Open-ILS/web/js/ui/default/acq/financial

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Dec 10 12:52:11 EST 2008


Author: erickson
Date: 2008-12-10 12:52:08 -0500 (Wed, 10 Dec 2008)
New Revision: 11501

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
Log:
use object-based store to ensure unique years, not array.indexOf

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	2008-12-10 17:43:40 UTC (rev 11500)
+++ trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js	2008-12-10 17:52:08 UTC (rev 11501)
@@ -33,18 +33,19 @@
 
             var yearStore = {identifier:'year', name:'year', items:[]};
 
-            var added = [];
+            var added = {};
             for(var i = 0; i < storeData.items.length; i++) {
                 var year = storeData.items[i].year;
-                if(added.indexOf(year) == -1) {
+                if(!(year in added)) {
                     yearStore.items.push({year:year});
-                    added.push(year);
+                    added[year] = 1;
                 }
             }
             yearStore.items = yearStore.items.sort().reverse();
             fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
             var today = new Date().getFullYear().toString();
-            fundFilterYearSelect.setValue((added.indexOf(today != -1)) ? today : added[0]);
+            if(today in added)
+                fundFilterYearSelect.setValue(today);
         }
     );
 }



More information about the open-ils-commits mailing list