From: erickson Date: Mon, 17 Aug 2009 16:16:22 +0000 (+0000) Subject: backporting -r13845:13848. fund year list api call, suppresse linked fields, fund... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=07b61e8e49031260fd40f281e534516cc372b9a2;p=Evergreen.git backporting -r13845:13848. fund year list api call, suppresse linked fields, fund year selector in fund list page using new call git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@13849 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm index 4c843f489e..54e7a7216e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm @@ -285,6 +285,11 @@ __PACKAGE__->register_method( } ); +__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 @@ sub retrieve_org_funds { $U->user_has_work_perm_at($e, $limit_perm, {descendants =>1}); return undef unless @{$filter->{org}}; - my $query = [ $filter, { @@ -310,6 +314,19 @@ sub retrieve_org_funds { } ]; + 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) { diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index 569b37ec5f..0b4a24213e 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -33,6 +33,7 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { 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(!dojo._hasResource['openils.widget.AutoFieldWidget']) { 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; diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index f903d7ac6e..f57f36a42f 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -26,6 +26,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { 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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { fmClass: this.grid.fmClass, fmField: this.field, widgetValue : val, - readOnly : true + readOnly : true, + suppressLinkedFields : this.grid.suppressLinkedFields }); var _this = this; diff --git a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js index 50f65ac52f..e44d7477a1 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js +++ b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js @@ -25,13 +25,15 @@ function getBalanceInfo(rowIndex, item) { return 0; } -function loadFundGrid(year) { - var yearStore = {identifier:'year', name:'year', items:[]}; - var yearsAdded = {}; /* don't duplicate the years in the selector */ - lfGrid.resetStore(); +function initPage() { + loadYearSelector(); + loadFundGrid(); +} - if(!year) year = new Date().getFullYear().toString(); +function loadFundGrid(year) { + lfGrid.resetStore(); + year = year || new Date().getFullYear().toString(); lfGrid.dataLoader = function() { loadFundGrid(year); }; fieldmapper.standardRequest( @@ -52,29 +54,40 @@ function loadFundGrid(year) { 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); - - lfGrid.hideLoadProgressIndicator(); + // default to this year + fundFilterYearSelect.setValue(new Date().getFullYear().toString()); dojo.connect( fundFilterYearSelect, 'onChange', function() { - loadFundGrid(fundFilterYearSelect.getValue()); + loadFundGrid(fundFilterYearSelect.attr('value')); } ); } @@ -82,6 +95,5 @@ function loadFundGrid(year) { ); } - -openils.Util.addOnLoad(loadFundGrid); +openils.Util.addOnLoad(initPage);