From: Bill Erickson Date: Thu, 22 Mar 2012 15:56:00 +0000 (-0400) Subject: ACQ fund admin UI improvements X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b9bb6d473cfc5e500218dcdf9f0cbd2875bdbac4;p=contrib%2FConifer.git ACQ fund admin UI improvements * Fund retrieval directly via AutoGrid/pcrud, now that pcrud supports fleshing. * Sort funds I can edit to the front of the list * Enable the new improved grid filter dialog * Leverage onItemReceived for caching funds for balanceInfo getter * Add some height to the grid to allow more rows to be visible in the page (without scrolling) Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/templates/acq/fund/list.tt2 b/Open-ILS/src/templates/acq/fund/list.tt2 index 83f2320b8d..95eac5fe45 100644 --- a/Open-ILS/src/templates/acq/fund/list.tt2 +++ b/Open-ILS/src/templates/acq/fund/list.tt2 @@ -139,14 +139,14 @@ -
+
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..5b212c6a76 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,18 +22,19 @@ var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); var contextOrg; var rolloverResponses; var rolloverMode = false; - -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; -} +var fundFleshFields = [ + 'spent_balance', + 'combined_balance', + 'spent_total', + 'encumbrance_total', + 'debit_total', + 'allocation_total' +]; + +var adminPermOrgs = []; +var cachedFunds = []; function initPage() { - contextOrg = openils.User.user.ws_ou(); var connect = function() { @@ -48,17 +49,29 @@ function initPage() { ); }; - dojo.connect(refreshButton, 'onClick', function() { rolloverMode = false; gridDataLoader(); }); + dojo.connect(refreshButton, 'onClick', + function() { rolloverMode = false; gridDataLoader(); }); new openils.User().buildPermOrgSelector( - 'ADMIN_ACQ_FUND', contextOrgSelector, contextOrg, connect); + ['ADMIN_ACQ_FUND', 'VIEW_FUND'], + contextOrgSelector, contextOrg, connect); dojo.byId('oils-acq-rollover-ctxt-org').innerHTML = fieldmapper.aou.findOrgUnit(contextOrg).shortname(); loadYearSelector(); - lfGrid.dataLoader = gridDataLoader; - loadFundGrid(new openils.CGI().param('year') || new Date().getFullYear().toString()); + lfGrid.onItemReceived = function(item) {cachedFunds.push(item)}; + + new openils.User().getPermOrgList( + 'ADMIN_ACQ_FUND', + function(list) { + adminPermOrgs = list; + loadFundGrid( + new openils.CGI().param('year') + || new Date().getFullYear().toString()); + }, + true, true + ); } function gridDataLoader() { @@ -75,36 +88,39 @@ function gridDataLoader() { } } -function loadFundGrid(year) { +function getBalanceInfo(rowIdx, item) { + if (!item) return ''; + var fundId = this.grid.store.getValue(item, 'id'); + var fund = cachedFunds.filter(function(f) { return f.id() == fundId })[0]; + var cb = fund.combined_balance(); + return cb ? cb.amount() : '0'; +} +function loadFundGrid(year) { openils.Util.hide('acq-fund-list-rollover-summary'); year = year || fundFilterYearSelect.attr('value'); + cachedFunds = []; - 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)); + lfGrid.loadAll( + { + flesh : 1, + flesh_fields : {acqf : fundFleshFields}, + + // by default, sort funds I can edit to the front + order_by : [ + { 'class' : 'acqf', + field : 'org', + compare : {'in' : adminPermOrgs}, + direction : 'desc' + }, + { 'class' : 'acqf', + field : 'name' } - }, - - oncomplete : function(r) { - lfGrid.hideLoadProgressIndicator(); - } - } + ] + }, { + year : year, + org : fieldmapper.aou.descendantNodeList(contextOrg, true) + } ); } @@ -113,7 +129,7 @@ function loadYearSelector() { fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.fund.org.years.retrieve'], { async : true, - params : [openils.User.authtoken], + params : [openils.User.authtoken, {}, {limit_perm : 'VIEW_FUND'}], oncomplete : function(r) { var yearList = openils.Util.readResponse(r);