From: erickson Date: Sat, 5 Apr 2008 17:31:23 +0000 (+0000) Subject: moved fund and funding_source list pages to grids X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a30e0ee23614a3847d04a033fadf6d5e09f3d27b;p=Evergreen.git moved fund and funding_source list pages to grids git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9238 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 2c2d705e23..857a2263d7 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -38,17 +38,7 @@ class FundController(BaseController): 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() diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py index 79de9b487c..ec9e1b46d4 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/funding_source.py @@ -26,20 +26,7 @@ class FundingSourceController(BaseController): return r.render('acq/financial/view_funding_source.html') def list(self): - r = RequestMgr() - ses = ClientSession(oils.const.OILS_APP_ACQ) - - 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') - + return RequestMgr().render('acq/financial/list_funding_sources.html') def create(self): r = RequestMgr() diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js new file mode 100644 index 0000000000..bbdde67669 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js @@ -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}; +}; +} + 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 new file mode 100644 index 0000000000..bd887b6e25 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js @@ -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}; +}; +} + 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 e496c7599e..8c2060c066 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 @@ -7,29 +7,27 @@
${_('Funding Sources')}
+
+ diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html index ec1ae659e9..e186133028 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html @@ -11,25 +11,24 @@ +
+