From 701fac36a803078bd4644a1c2d840cf27fcc4a35 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 22 Mar 2012 11:56:00 -0400 Subject: [PATCH] acq fund permacrud porting Signed-off-by: Bill Erickson --- .../web/js/ui/default/acq/financial/list_funds.js | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) 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 7da788d7ad..f9759fc35b 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 @@ -12,7 +12,7 @@ dojo.require('openils.Event'); dojo.require('openils.Util'); dojo.require('openils.User'); dojo.require('openils.CGI'); -dojo.require('openils.acq.Fund'); +dojo.require('openils.PermaCrud'); dojo.require('openils.widget.AutoGrid'); dojo.require('openils.widget.ProgressDialog'); dojo.require('fieldmapper.OrgUtils'); @@ -22,14 +22,18 @@ var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); var contextOrg; var rolloverResponses; var rolloverMode = false; +var fundFleshFields = [ + 'spent_balance', + 'combined_balance', + 'spent_total', + 'encumbrance_total', + 'debit_total', + 'allocation_total' +]; function getBalanceInfo(rowIndex, item) { if(!item) return ''; - var id = this.grid.store.getValue( item, 'id'); - var fund = openils.acq.Fund.cache[id]; - if(fund && fund.summary()) - return fund.summary().combined_balance; - return 0; + return this.grid.store.getValue(item, this.field) || 0; } function initPage() { @@ -80,27 +84,23 @@ function loadFundGrid(year) { openils.Util.hide('acq-fund-list-rollover-summary'); year = year || fundFilterYearSelect.attr('value'); - fieldmapper.standardRequest( - [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'], - { async: true, - - params: [ - openils.User.authtoken, - {year : year, org : fieldmapper.aou.descendantNodeList(contextOrg, true)}, - { - flesh_summary:1, - limit: lfGrid.displayLimit, - offset: lfGrid.displayOffset - } - ], - - onresponse : function(r) { - if(lf = openils.Util.readResponse(r)) { - openils.acq.Fund.cache[lf.id()] = lf; - lfGrid.store.newItem(acqf.toStoreItem(lf)); + var pcrud = new openils.PermaCrud(); + pcrud.search('acqf', + { year : year, + org : fieldmapper.aou.descendantNodeList(contextOrg, true) + }, + { flesh : 1, + flesh_fields : {acqf : fundFleshFields}, + streaming : true, + onresponse : function(r, obj) { + if(fund = openils.Util.readResponse(r)) { + fundFleshFields.forEach(function(ff) { + field = fund[ff](); + fund[ff](field ? field.amount() : '0'); + }); + lfGrid.store.newItem(acqf.toStoreItem(fund)); } }, - oncomplete : function(r) { lfGrid.hideLoadProgressIndicator(); } -- 2.11.0