From b8721de233a37491b014c46a78f32ef92a50953b Mon Sep 17 00:00:00 2001 From: erickson Date: Sat, 5 Apr 2008 13:04:16 +0000 Subject: [PATCH] Converted the provider list page to a JS/dojo grid version to start out with something simple Moved the Dojo CSS imports into the default skin css Added the opensrf and ILS JS imports into base.html. As noted in the source, some/many of those will also be dojo-ized over time. Added the configured prefix to all JS imports in the HTML files git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9237 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/provider.py | 7 +++ .../oilsweb/public/oils/media/css/skin/default.css | 13 +++++ .../public/oils/media/js/openils/acq/Provider.js | 58 ++++++++++++++++++++++ .../web/oilsweb/oilsweb/templates/oils/base.html | 57 +++++++++++++-------- .../oils/default/acq/financial/list_providers.html | 34 ++++++------- 5 files changed, 131 insertions(+), 38 deletions(-) create mode 100644 Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/provider.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/provider.py index 6bdd951895..ac1670258d 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/provider.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/provider.py @@ -50,6 +50,7 @@ class ProviderController(BaseController): return r.render('acq/financial/create_provider.html') + ''' Pure Python version def list(self): r = RequestMgr() providers = provider_mgr.list(r) @@ -57,4 +58,10 @@ class ProviderController(BaseController): f.owner(OrgUtil.get_org_unit(f.owner())) r.ctx.acq.provider_list.value = providers return r.render('acq/financial/list_providers.html') + ''' + + + def list(self): + return RequestMgr().render('acq/financial/list_providers.html') + diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css index 8eab61efd1..51e41c0bb3 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css @@ -1,6 +1,13 @@ /* import the default css for the install applications */ @import "default/acq.css"; @import "default/admin.css"; +/* import the dojo CSS */ +@import "../../js/dojo/dojox/grid/_grid/Grid.css"; +@import "../../js/dojo/dijit/themes/tundra/tundra.css"; +@import "../../js/dojo/dojo/resources/dojo.css"; + + + /* base default style */ @@ -39,3 +46,9 @@ html, body, #oils-base-body-block { .label { margin: 1px; } + +/* local dojo style enhancements ----------------------------------- */ +.dojoxGrid {border: 1px solid #333; height: 90%;} +.dojoxGrid-cell {padding: 8px;} +/* ----------------------------------------------------------------- */ + diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js new file mode 100644 index 0000000000..bc23948165 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js @@ -0,0 +1,58 @@ +if(!dojo._hasResource['openils.acq.Provider']) { +dojo._hasResource['openils.acq.Provider'] = true; +dojo.provide('openils.acq.Provider'); + +/** Declare the Provider class with dojo */ +dojo.declare('openils.acq.Provider', null, { + /* add instance methods here if necessary */ +}); + +/* define some static provider methods ------- */ + +openils.acq.Provider.createProviderGrid = function(domId, structure) { + /** Fetches the list of providers and builds a grid from them */ + openils.acq.Provider.fetchList( + function(providers) { + items = []; + for(var p in providers) { + var prov = providers[p]; + items.push({ + id:prov.id(), + name:prov.name(), + owner: findOrgUnit(prov.owner()).name(), + currency_type:prov.currency_type() + }); + } + openils.acq.Provider.buildGrid(domId, structure, items); + } + ); +} + +openils.acq.Provider.fetchList = function(callback) { + /** Retrieves the list of provider objects that I have permission to view */ + var ses = new OpenSRF.ClientSession('open-ils.acq'); + var req = ses.request('open-ils.acq.provider.org.retrieve', oilsAuthtoken); /* XXX make this a streaming call */ + req.oncomplete = function(r) { + callback(r.recv().content()); + }; + req.send(); +}; + +openils.acq.Provider.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/base.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html index cb35708aab..4a2b42696f 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html @@ -15,38 +15,55 @@ <%def name="page_title()">${_('Evergreen Acquisitions')} ${self.page_title()} ${self.block_css()} - ${self.block_js()} + ${self.block_js()} <%def name='block_body()'> -${self.block_body_content()} + ${self.block_body_content()} <%def name='block_body_content()'/> <%def name='block_css()'> - - - + + <%def name='block_js()'> - - + + + + + + + + + - dojo.require("dijit.form.Form") - dojo.require("dijit.form.Button"); - dojo.require("dijit.form.TextBox"); - dojo.require("dijit.form.NumberTextBox"); - dojo.require("dijit.form.NumberSpinner"); - dojo.require("dijit.form.FilteringSelect"); + + + + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html index e28816b31f..800e567490 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html @@ -10,24 +10,22 @@ ${_('New Provider')} +
+ -- 2.11.0