[open-ils-commits] r9422 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils/acq
oilsweb/oilsweb/templates/oils/default/acq/financial
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 21 22:37:33 EDT 2008
Author: erickson
Date: 2008-04-21 21:58:31 -0400 (Mon, 21 Apr 2008)
New Revision: 9422
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Provider.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html
Log:
updating provider grid code. added provider retrieval method
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Provider.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Provider.js 2008-04-22 01:26:47 UTC (rev 9421)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Provider.js 2008-04-22 01:58:31 UTC (rev 9422)
@@ -17,39 +17,55 @@
if(!dojo._hasResource['openils.acq.Provider']) {
dojo._hasResource['openils.acq.Provider'] = true;
dojo.provide('openils.acq.Provider');
-dojo.require('util.Dojo');
+dojo.require('fieldmapper.Fieldmapper');
/** Declare the Provider class with dojo */
dojo.declare('openils.acq.Provider', null, {
/* add instance methods here if necessary */
});
+openils.acq.Provider.cache = {};
+
/* define some static provider methods ------- */
-openils.acq.Provider.loadGrid = function(domId, columns) {
- /** Fetches the list of providers and builds a grid from them */
+openils.acq.Provider.createStore = function(onComplete, limitPerm) {
+ /** 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.provider.org.retrieve', openils.User.authtoken);
-
- req.oncomplete = function(r) {
- var msg
- gridRefs.grid.setModel(gridRefs.model);
+ function mkStore(r) {
+ var msg;
+ var items = [];
while(msg = r.recv()) {
- var prov = msg.content();
- gridRefs.store.newItem({
- id:prov.id(),
- name:prov.name(),
- owner: findOrgUnit(prov.owner()).name(),
- currency_type:prov.currency_type()
- });
+ var provider = msg.content();
+ openils.acq.Provider.cache[provider.id()] = provider;
+ items.push(provider);
}
- gridRefs.grid.update();
- };
+ onComplete(acqpro.toStoreData(items));
+ }
- req.send();
- return gridRefs.grid;
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.provider.org.retrieve'],
+ { async: true,
+ params: [openils.User.authtoken],
+ oncomplete: mkStore
+ }
+ );
};
+
+
+/**
+ * Synchronous provider retrievel method
+ */
+openils.acq.Provider.retrieve = function(id) {
+ if(openils.acq.Provider.cache[id])
+ return openils.acq.Provider.cache[id];
+
+ openils.acq.Provider.cache[id] =
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.provider.retrieve'],
+ [openils.User.authtoken, id]
+ );
+ return openils.acq.Provider.cache[id];
+};
+
}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html 2008-04-22 01:26:47 UTC (rev 9421)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_providers.html 2008-04-22 01:58:31 UTC (rev 9422)
@@ -1,28 +1,64 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
-<%namespace file='../../common/widgets.html' name='widget'/>
<%def name="page_title()">${_('Providers')}</%def>
<%def name="block_content()">
+<script type="text/javascript">
+ dojo.require("dijit.Dialog");
+ dojo.require("dijit.form.FilteringSelect");
+ dojo.require('openils.acq.Provider');
+ dojo.require('openils.Event');
+ dojo.require('openils.acq.CurrencyType');
+</script>
+
<div id='oils-acq-list-header' class='container'>
<div id='oils-acq-list-header-label'>${_('Providers')}</div>
- <div id='oils-acq-list-header-actions'>
- <a href='${c.oils.acq.prefix.value}/provider/create'>${_('New Provider')}</a>
- </div>
</div>
-<div id='oils-acq-provider-grid'> </div>
+
+<!-- The main grid lives here -->
+<div jsId='providerListGrid' dojoType="dojox.Grid"></div>
+
<script>
- dojo.require('openils.acq.Provider');
- /* define the layout columns */
- var cols = [
- {name: '${_("ID")}', field: 'id'},
- {name: '${_("Name")}', field: "name"},
- {name: '${_("Owner")}', field: "owner"},
- {name: '${_("Currency Type")}', field: "currency_type"}
- ];
+ function loadProviderGrid() {
+ openils.User.getBySession();
- /* build the provider grid on page load */
- dojo.addOnLoad(function(){openils.acq.Provider.loadGrid('oils-acq-provider-grid', cols)});
+ /** define how the primary grid is rendered */
+
+ function getOrgInfo(rowIndex) {
+ data = providerListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return fieldmapper.aou.findOrgUnit(data.owner).shortname();
+ }
+
+ function getName(rowIndex) {
+ data = providerListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return '<a href="${c.oils.acq.prefix.value}/provider/view/'+data.id+'">'+data.name+'</a>';
+ }
+
+ var gridStructure = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', get:getName, width:'auto'},
+ {name: '${_("Owner")}', get:getOrgInfo},
+ {name: '${_("Currency Type")}', field: "currency_type"}
+ ]]
+ }];
+
+ openils.acq.Provider.createStore(
+ function(storeData) {
+ var store = new dojo.data.ItemFileReadStore({data:storeData});
+ var model = new dojox.grid.data.DojoData(null, store,
+ {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+ providerListGrid.setStructure(gridStructure);
+ providerListGrid.setModel(model);
+ providerListGrid.update();
+ }
+ );
+ }
+
+ dojo.addOnLoad(loadProviderGrid);
</script>
+
</%def>
More information about the open-ils-commits
mailing list