[open-ils-commits] r9273 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
public/oils/media/js/openils/acq public/oils/media/js/util
templates/oils/default/acq/financial
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Apr 8 18:14:04 EDT 2008
Author: erickson
Date: 2008-04-08 17:36:53 -0400 (Tue, 08 Apr 2008)
New Revision: 9273
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
Log:
added support for expanding dojo grids. the util.Dojo code will almost certainly live somewhere else in the repo, but I want to get it down on paper for now... need to flesh out the expanded column for funding_sources
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js 2008-04-08 21:18:36 UTC (rev 9272)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js 2008-04-08 21:36:53 UTC (rev 9273)
@@ -8,6 +8,8 @@
/* add instance methods here if necessary */
});
+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 */
@@ -22,6 +24,7 @@
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(),
@@ -37,6 +40,35 @@
return gridRefs.grid;
};
+
+openils.acq.FundingSource.loadGrid = function(grid, model) {
+ /** 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',
+ oilsAuthtoken, null, {flesh_summary:1});
+
+ req.oncomplete = function(r) {
+ var msg
+ grid.setModel(model);
+ while(msg = r.recv()) {
+ var 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'])
+ });
+ }
+ grid.update();
+ };
+
+ req.send();
+};
+
+
+
/**
* Create a new funding source object
* @param fields Key/value pairs used to create the new funding source
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js 2008-04-08 21:18:36 UTC (rev 9272)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js 2008-04-08 21:36:53 UTC (rev 9273)
@@ -45,5 +45,56 @@
return {grid:grid, store:store, model:model};
};
+
+util.Dojo.expandoGridToggle = function (gridId, inIndex, inShow) {
+ var grid = dijit.byId(gridId);
+ grid.expandedRows[inIndex] = inShow;
+ grid.updateRow(inIndex);
}
+util.Dojo.buildExpandoGrid = function(domId, columns, getSubRowDetail, identColumn) {
+
+ 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]);
+ }
+
+ function getCheck(inRowIndex) {
+ var image = (this.grid.expandedRows[inRowIndex]) ? 'open.gif' : 'closed.gif';
+ var show = (this.grid.expandedRows[inRowIndex]) ? 'false' : 'true';
+ return '<img src="/oils/media/js/dojo/dojox/grid/tests/images/' + image +
+ '" onclick="util.Dojo.expandoGridToggle(\'' +
+ this.grid.id + '\',' + inRowIndex + ', ' + show + ')" height="11" width="11">';
+ }
+
+ /* XXX i18n name: */
+ columns.unshift({name: 'Details', width: 4.5, get: getCheck, styles: 'text-align: center;' });
+
+ var view = {
+ 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};
+};
+
+}
+
+
+
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html 2008-04-08 21:18:36 UTC (rev 9272)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html 2008-04-08 21:36:53 UTC (rev 9273)
@@ -75,27 +75,33 @@
<div id='oils-acq-funding-source-grid'> </div>
<script>
- dojo.require('openils.acq.FundingSource');
+ function loadFSGrid() {
+ dojo.require('openils.acq.FundingSource');
+ var fundingSourceGrid = null;
+
+ var gridCols = [
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', field: "name", width:'auto'},
+ {name: '${_("Owner")}', field: "owner", width:'auto'},
+ {name: '${_("Currency Type")}', field: "currency_type"},
+ {name: '${_("Balance")}', field: "balance"}
+ ];
- /* define the layout columns */
- var cols = [
- {name: '${_("ID")}', field: 'id', 'class':'id-column'},
- {name: '${_("Name")}', field: "name"},
- {name: '${_("Owner")}', field: "owner"},
- {name: '${_("Currency Type")}', field: "currency_type"},
- {name: '${_("Balance")}', field: "balance"}
- ];
+ function getSubRowDetail(inRowIndex) {
+ if (fundingSourceGrid.expandedRows[inRowIndex]) {
+ fsId = fundingSourceGrid.model.getDatum(inRowIndex, 0);
+ fs = openils.acq.FundingSource.cache[fsId];
+ return '<b>Viewing grid row for FS: ' + fs.name() + '</b>';
+ } else
+ return '';
+ }
+
+ var gridRefs = util.Dojo.buildExpandoGrid('oils-acq-funding-source-grid', gridCols, getSubRowDetail);
+ fundingSourceGrid = gridRefs.grid;
+ openils.acq.FundingSource.loadGrid(fundingSourceGrid, gridRefs.model);
+ }
- /* build the funding-source grid on page load */
- dojo.addOnLoad(
- function(){
- fsGrid = openils.acq.FundingSource.loadGrid('oils-acq-funding-source-grid', cols);
- fsGrid.onRowClick = function(evt) {
- /** XXX Need to make this more user friendly / obvious ... */
- id = fsGrid.model.getDatum(evt.rowIndex, 0);
- location.href = '${c.oils.acq.prefix.value}/funding_source/view/' + id;
- };
- }
- );
+ dojo.addOnLoad(loadFSGrid);
</script>
+
</%def>
More information about the open-ils-commits
mailing list