[open-ils-commits] r9238 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers/acq public/oils/media/js/openils/acq
templates/oils/default/acq/financial
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Apr 5 14:08:10 EDT 2008
Author: erickson
Date: 2008-04-05 13:31:23 -0400 (Sat, 05 Apr 2008)
New Revision: 9238
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py
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_funds.html
Log:
moved fund and funding_source list pages to grids
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py 2008-04-05 13:04:16 UTC (rev 9237)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py 2008-04-05 17:31:23 UTC (rev 9238)
@@ -38,17 +38,7 @@
return r.render('acq/financial/view_fund.html')
def list(self):
- r = RequestMgr()
- ses = ClientSession(oils.const.OILS_APP_ACQ)
- funds = ses.request(
- 'open-ils.acq.fund.org.retrieve',
- r.ctx.core.authtoken.value, None, {"flesh_summary":1}).recv().content()
- Event.parse_and_raise(funds)
- for f in funds:
- f.org(OrgUtil.get_org_unit(f.org()))
- r.ctx.acq.fund_list.value = funds
- return r.render('acq/financial/list_funds.html')
-
+ return RequestMgr().render('acq/financial/list_funds.html')
def create(self):
r = RequestMgr()
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py 2008-04-05 13:04:16 UTC (rev 9237)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py 2008-04-05 17:31:23 UTC (rev 9238)
@@ -26,21 +26,8 @@
return r.render('acq/financial/view_funding_source.html')
def list(self):
- r = RequestMgr()
- ses = ClientSession(oils.const.OILS_APP_ACQ)
+ return RequestMgr().render('acq/financial/list_funding_sources.html')
- sources = ses.request(
- 'open-ils.acq.funding_source.org.retrieve',
- r.ctx.core.authtoken.value, None, {"flesh_summary":1}).recv().content()
-
- Event.parse_and_raise(sources)
- r.ctx.acq.funding_source_list.value = sources
-
- for source in sources:
- source.owner(OrgUtil.get_org_unit(source.owner()))
- return r.render('acq/financial/list_funding_sources.html')
-
-
def create(self):
r = RequestMgr()
fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js 2008-04-05 17:31:23 UTC (rev 9238)
@@ -0,0 +1,61 @@
+if(!dojo._hasResource['openils.acq.Fund']) {
+dojo._hasResource['openils.acq.Fund'] = true;
+dojo.provide('openils.acq.Fund');
+
+/** Declare the Fund class with dojo */
+dojo.declare('openils.acq.Fund', null, {
+ /* add instance methods here if necessary */
+});
+
+/* define some static fund methods ------- */
+
+openils.acq.Fund.createFundGrid = function(domId, structure) {
+ /** Fetches the list of funds and builds a grid from them */
+ openils.acq.Fund.fetchList(
+ function(funds) {
+ items = [];
+ for(var f in funds) {
+ var fund = funds[f];
+ items.push({
+ id:fund.id(),
+ name:fund.name(),
+ org: findOrgUnit(fund.org()).name(),
+ currency_type:fund.currency_type(),
+ year:fund.year(),
+ combined_balance:fund.summary()['combined_balance']
+ });
+ }
+ openils.acq.Fund.buildGrid(domId, structure, items);
+ }
+ );
+}
+
+openils.acq.Fund.fetchList = function(callback) {
+ /** Retrieves the list of fund objects that I have permission to view */
+ var ses = new OpenSRF.ClientSession('open-ils.acq');
+ var req = ses.request('open-ils.acq.fund.org.retrieve',
+ oilsAuthtoken, null, {flesh_summary:1}); /* XXX make this a streaming call */
+ req.oncomplete = function(r) {
+ callback(r.recv().content());
+ };
+ req.send();
+};
+
+openils.acq.Fund.buildGrid = function(domId, structure, dataList, identifier) {
+ /** Builds a dojo grid based on the provided data.
+ * @param domId The DOM node where the grid lives
+ * @param structure The layout of the grid. i.e. colums.
+ * @param dataList List of objects (hashes) to be inserted into the grid.
+ * @paramd identifier The ID field for objects in the grid. Defaults to 'id'
+ */
+ identifier = (identifier) ? identifier : 'id';
+ var store = new dojo.data.ItemFileWriteStore({data:{identifier:identifier,items:dataList}});
+ var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true});
+ var grid = new dojox.Grid({structure: structure, model: model}, dojo.byId(domId));
+ grid.setModel(model);
+ grid.setStructure(structure);
+ grid.startup();
+ return {grid:grid, store:store, model:model};
+};
+}
+
Added: 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 (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js 2008-04-05 17:31:23 UTC (rev 9238)
@@ -0,0 +1,60 @@
+if(!dojo._hasResource['openils.acq.FundingSource']) {
+dojo._hasResource['openils.acq.FundingSource'] = true;
+dojo.provide('openils.acq.FundingSource');
+
+/** Declare the FundingSource class with dojo */
+dojo.declare('openils.acq.FundingSource', null, {
+ /* add instance methods here if necessary */
+});
+
+/* define some static methods ------- */
+
+openils.acq.FundingSource.createFundingSourceGrid = function(domId, structure) {
+ /** Fetches the list of funding_sources and builds a grid from them */
+ openils.acq.FundingSource.fetchList(
+ function(srcs) {
+ items = [];
+ for(var f in srcs) {
+ var src = srcs[f];
+ items.push({
+ id:src.id(),
+ name:src.name(),
+ owner: findOrgUnit(src.owner()).name(),
+ currency_type:src.currency_type(),
+ balance:src.summary()['balance']
+ });
+ }
+ openils.acq.FundingSource.buildGrid(domId, structure, items);
+ }
+ );
+}
+
+openils.acq.FundingSource.fetchList = function(callback) {
+ /** Retrieves the list of fund objects that I have permission to view */
+ var ses = new OpenSRF.ClientSession('open-ils.acq');
+ var req = ses.request('open-ils.acq.funding_source.org.retrieve',
+ oilsAuthtoken, null, {flesh_summary:1}); /* XXX make this a streaming call */
+ req.oncomplete = function(r) {
+ callback(r.recv().content());
+ };
+ req.send();
+};
+
+openils.acq.FundingSource.buildGrid = function(domId, structure, dataList, identifier) {
+ /** Builds a dojo grid based on the provided data.
+ * @param domId The DOM node where the grid lives
+ * @param structure The layout of the grid. i.e. colums.
+ * @param dataList List of objects (hashes) to be inserted into the grid.
+ * @paramd identifier The ID field for objects in the grid. Defaults to 'id'
+ */
+ identifier = (identifier) ? identifier : 'id';
+ var store = new dojo.data.ItemFileWriteStore({data:{identifier:identifier,items:dataList}});
+ var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true});
+ var grid = new dojox.Grid({structure: structure, model: model}, dojo.byId(domId));
+ grid.setModel(model);
+ grid.setStructure(structure);
+ grid.startup();
+ return {grid:grid, store:store, 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-05 13:04:16 UTC (rev 9237)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html 2008-04-05 17:31:23 UTC (rev 9238)
@@ -7,29 +7,27 @@
<div id='oils-acq-list-header' class='container'>
<div id='oils-acq-list-header-label'>${_('Funding Sources')}</div>
<div id='oils-acq-list-header-actions'>
- <a href='${c.oils.acq.prefix.value}/funding_source/create'>${_('New Funding Source')}</a>
+ <a href='${c.oils.acq.prefix.value}/funding-sourceing_source/create'>${_('New Funding Source')}</a>
</div>
</div>
+<div id='oils-acq-funding-source-grid'> </div>
+<script>
+ dojo.require('openils.acq.FundingSource');
-<table class='oils-admin-table'>
- <thead>
- <tr>
- <td>${_('Funding Source Name')}</td>
- <td>${_('Funding Source Owner')}</td>
- <td>${_('Funding Source Currency Type')}</td>
- <td>${_('Funding Source Balance')}</td>
- </tr>
- </thead>
- <tbody>
- % for source in c.oils.acq.funding_source_list.value:
- <tr>
- <td><a href='${c.oils.acq.prefix.value}/funding_source/view/${source.id()}'>${source.name()}</a></td>
- <td>${source.owner().name()}</td>
- <td>${source.currency_type()}</td>
- <td>${source.summary()['balance']}</td>
- </tr>
- %endfor
- </tbody>
-</table>
+ /* define the layout columns */
+ var cols = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', field: "name"},
+ {name: '${_("Owner")}', field: "owner"},
+ {name: '${_("Currency Type")}', field: "currency_type"},
+ {name: '${_("Balance")}', field: "balance"}
+ ]]
+ }];
+
+ /* build the funding-source grid on page load */
+ dojo.addOnLoad(function(){
+ openils.acq.FundingSource.createFundingSourceGrid('oils-acq-funding-source-grid', cols)});
+</script>
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html 2008-04-05 13:04:16 UTC (rev 9237)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html 2008-04-05 17:31:23 UTC (rev 9238)
@@ -11,25 +11,24 @@
</div>
</div>
+<div id='oils-acq-fund-grid'> </div>
+<script>
+ dojo.require('openils.acq.Fund');
-<table class='oils-admin-table'>
- <thead>
- <tr>
- <td>${_('Fund Name')}</td>
- <td>${_('Fund Owner')}</td>
- <td>${_('Fund Year')}</td>
- <td>${_('Fund Balance')}</td>
- </tr>
- </thead>
- <tbody>
- % for fund in c.oils.acq.fund_list.value:
- <tr>
- <td><a href='${c.oils.acq.prefix.value}/fund/view/${fund.id()}'>${fund.name()}</a></td>
- <td>${fund.org().name()}</td>
- <td>${fund.year()}</td>
- <td>${fund.summary()['combined_balance']}</td>
- </tr>
- %endfor
- </tbody>
-</table>
+ /* define the layout columns */
+ var cols = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', field: "name"},
+ {name: '${_("Owner")}', field: "org"},
+ {name: '${_("Year")}', field: "year"},
+ {name: '${_("Currency Type")}', field: "currency_type"},
+ {name: '${_("Balance")}', field: "combined_balance"}
+ ]]
+ }];
+
+ /* build the fund grid on page load */
+ dojo.addOnLoad(function(){
+ openils.acq.Fund.createFundGrid('oils-acq-fund-grid', cols)});
+</script>
</%def>
More information about the open-ils-commits
mailing list