[open-ils-commits] r9463 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils/acq
oilsweb/oilsweb/templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Apr 27 22:12:37 EDT 2008
Author: djfiander
Date: 2008-04-27 21:32:44 -0400 (Sun, 27 Apr 2008)
New Revision: 9463
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html
Log:
Functioning Picklist grid.
TODO: use vendor names, not indices, and hook up line item detail display
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-04-28 01:25:36 UTC (rev 9462)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-04-28 01:32:44 UTC (rev 9463)
@@ -1,52 +1,71 @@
+/* ---------------------------------------------------------------------------
+ * Copyright (C) 2008 Georgia Public Library Service
+ * David J. Fiander <david at fiander.info>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * ---------------------------------------------------------------------------
+ */
+
if(!dojo._hasResource['openils.acq.Picklist']) {
dojo._hasResource['openils.acq.Picklist'] = true;
dojo.provide('openils.acq.Picklist');
-dojo.require('util.Dojo');
+dojo.require('fieldmapper.Fieldmapper');
+
/** Declare the Picklist class with dojo */
dojo.declare('openils.acq.Picklist', null, {
/* add instance methods here if necessary */
});
- openils.acq.Picklist.find_attr = function(li, at_name, at_type) {
- for (var i in li.attributes()) {
- var attr = li.attributes()[i];
- if (attr.attr_type() == at_type && attr.attr_name() == at_name) {
- return attr.attr_value();
- }
- }
- return '';
- };
+openils.acq.Picklist.cache = {};
+openils.acq.Picklist.createStore = function(pl_id, onComplete) {
+ // Fetches the list of titles in a picklist and builds a grid
- openils.acq.Picklist.loadGrid = function(domId, columns, pl_id) {
- /** Fetches the list of picklists and builds a grid from them */
+ function mkStore(r) {
+ var msg;
+ var items = [];
+ while (msg = r.recv()) {
+ var data = msg.content();
+ openils.acq.Picklist.cache[data.id()] = data;
- var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true);
- var ses = new OpenSRF.ClientSession('open-ils.acq');
- var req = ses.request('open-ils.acq.lineitem.picklist.retrieve',
- openils.User.authtoken, pl_id, {flesh_attrs:1});
+ items.push(data);
+ }
+ onComplete(jub.toStoreData(items));
+ }
- req.oncomplete = function(r) {
- var msg
- gridRefs.grid.setModel(gridRefs.model);
- gridRefs.model.query = {id:'*'};
- while(msg = r.recv()) {
- var jub = msg.content();
- //alert(js2JSON(jub));
- gridRefs.store.newItem({
- id:jub.id(),
- title:openils.acq.Picklist.find_attr(jub, "title", "lineitem_marc_attr_definition"),
- price:openils.acq.Picklist.find_attr(jub, "price", "lineitem_marc_attr_definition"),
- provider:jub.provider(),
- copies:jub.item_count()
- });
- }
- gridRefs.grid.update();
- };
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem.picklist.retrieve'],
+ { async: true,
+ params: [openils.User.authtoken, pl_id, {flesh_attrs:1}],
+ oncomplete: mkStore
+ });
+};
- req.send();
- return gridRefs.grid;
+openils.acq.Picklist.find_attr = function(id, at_name, at_type) {
+ var li = openils.acq.Picklist.cache[id];
+ for (var i in li.attributes()) {
+ var attr = li.attributes()[i];
+ if (attr.attr_type() == at_type && attr.attr_name() == at_name) {
+ return attr.attr_value();
+ }
+ }
+ return '';
};
+
+openils.acq.Picklist.onRowClick = function(evt) {
+ var gridRefs = openils.acq.Picklist._gridRefs;
+ var row = gridRefs.grid.model.getRow(evt.rowIndex);
+
+ openils.acq.Lineitems.loadGrid('oils-acq-picklist-details-grid', row.id);
+};
}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html 2008-04-28 01:25:36 UTC (rev 9462)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html 2008-04-28 01:32:44 UTC (rev 9463)
@@ -11,7 +11,20 @@
<script type="text/javascript">
dojo.require("dijit.layout.SplitContainer")
+ dojo.require('openils.acq.Picklist');
</script>
+ <script type='text/javascript'>
+ function getJUBTitle(rowIndex) {
+ data = pickListGrid.model.getRow(rowIndex);
+ if (!data) return '';
+ return openils.acq.Picklist.find_attr(data.id, "title", "lineitem_marc_attr_definition")
+ }
+ function getJUBPrice(rowIndex) {
+ data = pickListGrid.model.getRow(rowIndex);
+ if (!data) return;
+ return openils.acq.Picklist.find_attr(data.id, "price", "lineitem_marc_attr_definition")
+ }
+ </script>
</%def>
<%def name="page_title()">${_('Picklist')}</%def>
@@ -22,29 +35,51 @@
</div>
<div dojoType="dijit.layout.SplitContainer"
orientation="vertical" sizerWidth="5"
- activeSizing="0" layoutAlign="client">
- <div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="20">
- <div id="oils-acq-picklist-grid"> </div>
- <script type="text/javascript" src="${c.oils.core.media_prefix.value}/js/util/Dojo.js"></script>
- <script type="text/javascript" src="${c.oils.core.media_prefix.value}/js/openils/acq/Picklist.js"></script>
+ activeSizing="1" layoutAlign="client">
+ <div id="oils-acq.picklist-container"
+ dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="20">
+ <div jsid='pickListGrid' dojoType='dojox.Grid'
+ id="oils-acq-picklist-grid"> </div>
<script type="text/javascript">
- dojo.require('openils.acq.Picklist');
-
- var cols = [
- {name: "${_('ID')}", field: 'id'},
- {name: "${_('Title')}", width: "50%", field: 'title'},
- {name: "${_('Price')}", field: 'price'},
- {name: "${_('Vendor')}", field: 'provider'},
- {name: "${_('# of Copies')}", field: 'copies'}
- ];
-
- dojo.addOnLoad(function(){openils.acq.Picklist.loadGrid('oils-acq-picklist-grid', cols, ${c.oils.acq.picklist.value.id()})});
+ dojo.require("openils.acq.Picklist");
+ dojo.require('dojo.data.ItemFileWriteStore');
+ var layout = [{
+ cells: [[
+ {name: "ID", field: 'id'},
+ {name: "Title", width: "50%", get:getJUBTitle},
+ {name: "Price", get:getJUBPrice},
+ {name: "Vendor", field: 'provider'},
+ {name: "# of Copies", field: 'item_count'}
+ ]]
+ }];
+
+ openils.acq.Picklist.createStore(${c.oils.acq.picklist.value.id()},
+ 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:'*'}});
+ pickListGrid.setStructure(layout);
+ pickListGrid.setModel(model);
+ pickListGrid.update();
+ });
</script>
</div>
<div dojoType="dijit.layout.ContentPane" sizeMin="20"
sizeShare="80">
- <p>Hi!</p>
- <div id="oils-acq-picklist-details-grid"> </div>
+ <script type="text/javascript">
+ dojo.require("openils.acq.Lineitems");
+
+ var li_cols = [
+ {name: ('Fund'), field: 'fund'},
+ {name: ('Location'), field: 'location'}
+ ];
+
+ dojo.addOnLoad(function(){openils.acq.Lineitems.initGrid('oils-acq-picklist-details-grid', li_cols);});
+ </script>
+ <div id="oils-acq-picklist-details-grid">
+ <p>Copy order details go here...</p>
+ </div>
</div>
</div>
</div>
More information about the open-ils-commits
mailing list