From 96567d78110e9c6e1e245a0aeaffa484b90fd58e Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 9 Apr 2008 18:32:20 +0000 Subject: [PATCH] now using fieldmapper.dojoData to build the data store for funding sources (thanks, mike). updated version of grid sub-row code. this actually builds a sub-grid on the fly (as an example), but could be extended to support arbitrary dom nodes. needs considerable tidying.. git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9283 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oils/media/js/openils/acq/FundingSource.js | 49 +---- .../oilsweb/public/oils/media/js/util/Dojo.js | 16 +- .../acq/financial/list_funding_sources.html | 203 ++++++++++++++------- 3 files changed, 156 insertions(+), 112 deletions(-) diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js index b2b8da2a9c..c455962b85 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js @@ -8,40 +8,10 @@ dojo.declare('openils.acq.FundingSource', null, { /* add instance methods here if necessary */ }); +/** cached funding_source objects */ openils.acq.FundingSource.cache = {}; -//openils.acq.FundingSource.loadGrid = function(domId, columns, gridBuiltHandler) { -openils.acq.FundingSource.loadGrid = function(domId, columns) { - /** Fetches the list of funding_sources and builds a grid from them */ - - var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true); - var ses = new OpenSRF.ClientSession('open-ils.acq'); - var req = ses.request('open-ils.acq.funding_source.org.retrieve', - oilsAuthtoken, null, {flesh_summary:1}); - - req.oncomplete = function(r) { - var msg - gridRefs.grid.setModel(gridRefs.model); - while(msg = r.recv()) { - var src = msg.content(); - openils.acq.FundingSource.cache[src.id()] = src; - gridRefs.store.newItem({ - id:src.id(), - name:src.name(), - owner: findOrgUnit(src.owner()).name(), - currency_type:src.currency_type(), - balance:new String(src.summary()['balance']) - }); - } - gridRefs.grid.update(); - }; - - req.send(); - return gridRefs.grid; -}; - - -openils.acq.FundingSource.loadGrid = function(grid, model) { +openils.acq.FundingSource.createStore = function(onComplete) { /** Fetches the list of funding_sources and builds a grid from them */ var ses = new OpenSRF.ClientSession('open-ils.acq'); var req = ses.request('open-ils.acq.funding_source.org.retrieve', @@ -49,19 +19,14 @@ openils.acq.FundingSource.loadGrid = function(grid, model) { req.oncomplete = function(r) { var msg - grid.setModel(model); + var items = []; + var src = null; while(msg = r.recv()) { - var src = msg.content(); + src = msg.content(); openils.acq.FundingSource.cache[src.id()] = src; - model.store.newItem({ - id:src.id(), - name:src.name(), - owner: findOrgUnit(src.owner()).name(), - currency_type:src.currency_type(), - balance:new String(src.summary()['balance']) - }); + items.push(src); } - grid.update(); + onComplete(acqfs.toStoreData(items)); }; req.send(); diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js index d27e43cb72..693e0aaa81 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js @@ -52,13 +52,14 @@ util.Dojo.expandoGridToggle = function (gridId, inIndex, inShow) { grid.updateRow(inIndex); } -util.Dojo.buildExpandoGrid = function(domId, columns, getSubRowDetail, identColumn) { +/** + * Constructs an expandable dojox.Grid + * @param getSubRowDetail called when the sub-row is expanded. Should return HTML + */ +util.Dojo.buildExpandoGrid = function(domId, columns, getSubRowDetail) { - identColumn = (identColumn) ? identColumn : 'id'; var grid = new dojox.Grid({}, domId); - var rowBar = {type: 'dojox.GridRowView', width: '20px' }; - function onBeforeRow(inDataIndex, inRow) { inRow[1].hidden = (!grid.expandedRows || !grid.expandedRows[inDataIndex]); } @@ -66,6 +67,7 @@ util.Dojo.buildExpandoGrid = function(domId, columns, getSubRowDetail, identColu function getCheck(inRowIndex) { var image = (this.grid.expandedRows[inRowIndex]) ? 'open.gif' : 'closed.gif'; var show = (this.grid.expandedRows[inRowIndex]) ? 'false' : 'true'; + /* XXX JS var for JS root */ return ''; @@ -78,19 +80,15 @@ util.Dojo.buildExpandoGrid = function(domId, columns, getSubRowDetail, identColu onBeforeRow: onBeforeRow, cells: [ columns, - /* XXX i18n name: */ [{ name: 'Detail', colSpan: columns.length, get: getSubRowDetail }] ] }; grid.setStructure([rowBar, view]); - - var store = new dojo.data.ItemFileWriteStore({data:{identifier:identColumn, items:[]}}); - var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true}); grid.startup(); grid.expandedRows = []; - return {grid:grid, model:model}; + return grid; }; } diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html index 93d846d03e..7bf9a05bfc 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html @@ -6,11 +6,6 @@
${_('Funding Sources')}
-
@@ -34,79 +29,165 @@
-
- ${('New Funding Source')} -
- - - - - - - - - - - - - - - - -
- -
- -
- -
-
-
- - +
+ ${('New Funding Source')} +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+
+
+