[open-ils-commits] r13849 - in branches/rel_1_6/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/dojo/openils/widget web/js/ui/default/acq/financial (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Aug 17 12:16:25 EDT 2009


Author: erickson
Date: 2009-08-17 12:16:22 -0400 (Mon, 17 Aug 2009)
New Revision: 13849

Modified:
   branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
   branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
   branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   branches/rel_1_6/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
Log:
backporting -r13845:13848.  fund year list api call, suppresse linked fields, fund year selector in fund list page using new call

Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2009-08-17 16:14:51 UTC (rev 13848)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2009-08-17 16:16:22 UTC (rev 13849)
@@ -285,6 +285,11 @@
     }
 );
 
+__PACKAGE__->register_method(
+	method => 'retrieve_org_funds',
+	api_name	=> 'open-ils.acq.fund.org.years.retrieve');
+
+
 sub retrieve_org_funds {
     my($self, $conn, $auth, $filter, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
@@ -300,7 +305,6 @@
         $U->user_has_work_perm_at($e, $limit_perm, {descendants =>1});
     return undef unless @{$filter->{org}};
 
-
     my $query = [
         $filter,
         {
@@ -310,6 +314,19 @@
         }
     ];
 
+    if($self->api_name =~ /years/) {
+        # return the distinct set of fund years covered by the selected funds
+        my $data = $e->json_query({
+            select => {
+                acqf => [{column => 'year', transform => 'distinct'}]
+            }, 
+            from => 'acqf', 
+            where => $filter}
+        );
+
+        return [map { $_->{year} } @$data];
+    }
+
     my $funds = $e->search_acq_fund($query);
 
     for my $fund (@$funds) {

Modified: branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-08-17 16:14:51 UTC (rev 13848)
+++ branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-08-17 16:16:22 UTC (rev 13849)
@@ -33,6 +33,7 @@
             if(this.fmObject) 
                 this.fmClass = this.fmObject.classname;
             this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
+            this.suppressLinkedFields = args.suppressLinkedFields || [];
 
             if(!this.idlField) {
                 this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
@@ -200,6 +201,10 @@
             if(this.idlField.datatype == 'org_unit')
                 return false; // we already handle org_units, no need to re-fetch
 
+            // user opted to bypass fetching this linked data
+            if(this.suppressLinkedFields.indexOf(this.idlField.name) > -1)
+                return false;
+
             var linkInfo = this._getLinkSelector();
             if(!(linkInfo && linkInfo.vfield && linkInfo.vfield.selector)) 
                 return false;

Modified: branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-08-17 16:14:51 UTC (rev 13848)
+++ branches/rel_1_6/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-08-17 16:16:22 UTC (rev 13849)
@@ -26,6 +26,7 @@
             displayLimit : 15,
             displayOffset : 0,
             showPaginator : false,
+            suppressLinkedFields : null, // list of fields whose linked display data should not be fetched from the server
 
             /* by default, don't show auto-generated (sequence) fields */
             showSequenceFields : false, 
@@ -538,7 +539,8 @@
             fmClass: this.grid.fmClass,
             fmField: this.field,
             widgetValue : val,
-            readOnly : true
+            readOnly : true,
+            suppressLinkedFields : this.grid.suppressLinkedFields
         });
 
         var _this = this;

Modified: branches/rel_1_6/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/js/ui/default/acq/financial/list_funds.js	2009-08-17 16:14:51 UTC (rev 13848)
+++ branches/rel_1_6/Open-ILS/web/js/ui/default/acq/financial/list_funds.js	2009-08-17 16:16:22 UTC (rev 13849)
@@ -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