[open-ils-commits] r9665 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils/acq
oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po
oilsweb/oilsweb/templates/oils/default/acq/picklist
oilsweb/oilsweb/templates/oils/default/acq/po
oilsweb/oilsweb/templates/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu May 22 11:54:07 EDT 2008
Author: erickson
Date: 2008-05-22 11:54:05 -0400 (Thu, 22 May 2008)
New Revision: 9665
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js
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/po/li_search.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html
Log:
moved jubgrid JS to external file
added isbn and pubdate columns
when jubgrid is used, you have to provide a list of lineitems directly
so it knows how to find the lineitem-attr fields
put jubgrid JS into an object (currently called JUBGrid) to contain
the helper functions and grid references (less global namespace collision opportunities);
updated picklist/view and li_search to use this updated grid
Picklist now stores an array of lineitems refs in addition to the _data object
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-05-22 15:44:42 UTC (rev 9664)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-05-22 15:54:05 UTC (rev 9665)
@@ -31,15 +31,15 @@
var mkStore = function (r) {
var storeData;
var msg;
- var items = [];
+ pl_this._items = [];
while (msg = r.recv()) {
var data = msg.content();
pl_this._data[data.id()] = data;
- items.push(data);
+ pl_this._items.push(data);
}
- storeData = jub.toStoreData(items);
+ storeData = jub.toStoreData(pl_this._items);
pl_this._store = new dojo.data.ItemFileWriteStore({data:storeData});
pl_this._model = new dojox.grid.data.DojoData(null, pl_this._store,
{rowsPerPage:20, clientSort:true,
@@ -65,7 +65,7 @@
fieldmapper.standardRequest(
['open-ils.acq', 'open-ils.acq.lineitem.picklist.retrieve'],
{ async: true,
- params: [openils.User.authtoken, pl_id, {flesh_attrs:1}],
+ params: [openils.User.authtoken, pl_id, {flesh_attrs:1, clear_marc:1}],
oncomplete: mkStore
});
},
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js 2008-05-22 15:44:42 UTC (rev 9664)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js 2008-05-22 15:54:05 UTC (rev 9665)
@@ -68,54 +68,9 @@
var store = new dojo.data.ItemFileReadStore({data:jub.toStoreData(lineitems)});
var model = new dojox.grid.data.DojoData(
null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
- liGrid.setModel(model);
- liGrid.update();
+ JUBGrid.populate(liGrid, model, lineitems)
}
-
-function getProvider(rowIndex) {
- data = liGrid.model.getRow(rowIndex);
- if(!data) return;
- if(!data.provider) return '';
- return openils.acq.Provider.retrieve(data.provider).code();
-}
-
-function getLi(id) {
- for(var i in lineitems) {
- var li = lineitems[i];
- if(li.id() == id)
- return li;
- }
-}
-
-function getJUBTitle(rowIndex) {
- var data = liGrid.model.getRow(rowIndex);
- if(!data) return '';
- return new openils.acq.Lineitems(
- {lineitem:getLi(data.id)}).findAttr('title', 'lineitem_marc_attr_definition')
-}
-
-function getJUBIsbn(rowIndex) {
- var data = liGrid.model.getRow(rowIndex);
- if(!data) return '';
- return new openils.acq.Lineitems(
- {lineitem:getLi(data.id)}).findAttr('isbn', 'lineitem_marc_attr_definition')
-}
-
-function getJUBPubdate(rowIndex) {
- var data = liGrid.model.getRow(rowIndex);
- if(!data) return '';
- return new openils.acq.Lineitems(
- {lineitem:getLi(data.id)}).findAttr('pubdate', 'lineitem_marc_attr_definition')
-}
-
-function getJUBPrice(rowIndex) {
- var data = liGrid.model.getRow(rowIndex);
- if(!data) return;
- return new openils.acq.Lineitems(
- {lineitem:getLi(data.id)}).findAttr('price', 'lineitem_marc_attr_definition')
-}
-
function createPOFromLineitems() {
var po = new acqpo()
po.provider(newPOProviderSelector.getValue());
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-05-22 15:44:42 UTC (rev 9664)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html 2008-05-22 15:54:05 UTC (rev 9665)
@@ -9,6 +9,7 @@
<script type='text/javascript'>
dojo.require('dijit.layout.LayoutContainer');
dojo.require('dijit.layout.ContentPane');
+ dojo.require('openils.acq.Picklist');
</script>
</%def>
<%def name="page_title()">${_('Picklist')}</%def>
@@ -36,8 +37,7 @@
dojo.byId("oils-acq-picklist-attr-cdate").innerHTML = plist.create_time();
dojo.byId("oils-acq-picklist-attr-edate").innerHTML = plist.edit_time();
dojo.byId("oils-acq-picklist-attr-owner").innerHTML = plist.owner();
-
- populateJUBGrid(pickListGrid, model);
+ JUBGrid.populate(pickListGrid, model, plist._items);
});
}
dojo.addOnLoad(loadPL);
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/li_search.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/li_search.html 2008-05-22 15:44:42 UTC (rev 9664)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/li_search.html 2008-05-22 15:54:05 UTC (rev 9665)
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
<%inherit file='base.html'/>
<%def name="page_title()">${_('Lineitem Search')}</%def>
+<%namespace file='/oils/default/common/jubgrid.html' name='jubgrid'/>
+
<%def name="block_content()">
<script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/acq/po/li_search.js'> </script>
<script>
@@ -70,23 +72,7 @@
</table>
</div>
</div>
-
-
- <script>
- var liGridStructure = [{
- cells: [[
- {name: '${_("ID")}', field: 'id'},
- {name: '${_("Title")}', width: 'auto', get:getJUBTitle},
- {name: '${_("ISBN")}', get:getJUBIsbn},
- {name: '${_("Pubdate")}', get:getJUBPubdate},
- {name: '${_("Price")}', get:getJUBPrice},
- {name: '${_("Vendor")}', get:getProvider},
- {name: '${_("# of Copies")}', field: 'item_count'},
- {name: '${_("State")}', field: 'state'}
- ]]
- }];
- </script>
- <div jsId='liGrid' dojoType="dojox.Grid" structure='liGridStructure'> </div>
+ ${jubgrid.jubgrid('oils-acq-lineitem', 'liGrid')}
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html 2008-05-22 15:44:42 UTC (rev 9664)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html 2008-05-22 15:54:05 UTC (rev 9665)
@@ -36,102 +36,47 @@
pointing to the JUB model (and store) that you have created.
</%doc>
-<div dojoType="dijit.layout.SplitContainer"
+
+<div dojoType="dijit.layout.SplitContainer" style='height:100%'
orientation="vertical" sizerWidth="5"
activeSizing="1" layoutAlign="client">
- <script type="text/javascript">
- dojo.require('dojo.data.ItemFileReadStore');
- dojo.require('dijit.layout.SplitContainer');
- dojo.require('dojox.grid.Grid');
- dojo.require('openils.editors');
- dojo.require('openils.acq.Picklist');
- dojo.require("openils.acq.Fund");
- dojo.require('openils.acq.Provider');
- dojo.require("openils.acq.Lineitems");
- dojo.require("openils.widget.FundSelector");
- dojo.require("fieldmapper.OrgUtils");
- var globalUser = new openils.User();
- function getJUBTitle(rowIndex) {
- var data = ${grid_jsid}.model.getRow(rowIndex);
- if (!data) return '';
- return plist.find_attr(data.id, "title", "lineitem_marc_attr_definition")
- }
- function getJUBPrice(rowIndex) {
- var data = ${grid_jsid}.model.getRow(rowIndex);
- if (!data) return;
- return plist.find_attr(data.id, "price", "lineitem_marc_attr_definition")
- }
- function getJUBProvider(rowIndex) {
- var data = ${grid_jsid}.model.getRow(rowIndex);
- if (!data || !data.provider) return;
- return openils.acq.Provider.retrieve(data.provider).name();
- }
- function getLIDFundName(rowIndex) {
- var data = lineItemGrid.model.getRow(rowIndex);
- if (!data || !data.fund) return;
- try {
- return openils.acq.Fund.retrieve(data.fund).name();
- } catch (evt) {
- return data.fund;
- }
- }
- function getLIDLibName(rowIndex) {
- var data = lineItemGrid.model.getRow(rowIndex);
- if (!data || !data.owning_lib) return;
- try {
- return fieldmapper.aou.findOrgUnit(data.owning_lib, true).name();
- } catch (evt) {
- return data.owning_lib;
- }
- }
+ <script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/common/jubgrid.js'> </script>
+ <script>
+ JUBGrid.jubGridLayout = [{
+ cells: [[
+ {name: "ID", field: 'id'},
+ {name: "Title", width: "auto", get:JUBGrid.getJUBTitle},
+ {name: "ISBN", get:JUBGrid.getJUBIsbn},
+ {name: '${_("Pubdate")}', get:JUBGrid.getJUBPubdate},
+ {name: "Price", get:JUBGrid.getJUBPrice},
+ {name: "Vendor", get:JUBGrid.getProvider},
+ {name: "# of Copies", field: 'item_count'},
+ {name: "State", field: 'state'}
+ ]]
+ }];
+
+ JUBGrid.jubDetailGridLayout = [{
+ cells: [[
+ {name:"ID", field:"id"},
+ {name:"Fund", field:"fund",
+ get:JUBGrid.getLIDFundName,
+ editor: openils.widget.FundSelector,
+ },
+ {name:"Location", field:"location", get:JUBGrid.getLIDLibName}
+ ]]
+ }];
</script>
- <div id=${domprefix + '-container'}
- dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
- <div jsid=${grid_jsid} dojoType='dojox.Grid'
- id=${domprefix + '-JUB-grid'}> </div>
- <script type="text/javascript">
- var picklistLayout = [{
- cells: [[
- {name: "ID", field: 'id'},
- {name: "Title", width: "50%", get:getJUBTitle},
- {name: "Price", get:getJUBPrice},
- {name: "Vendor", field: 'provider',
- get:getJUBProvider},
- {name: "# of Copies", field: 'item_count'}
- ]]
- }];
- var lineitemLayout = [{
- cells: [[
- {name:"ID", field:"id"},
- {name:"Fund", field:"fund",
- get:getLIDFundName,
- editor: openils.widget.FundSelector,
- },
- {name:"Location", field:"location",
- get:getLIDLibName}
- ]]
- }];
- function populateJUBGrid(gridDom, model) {
- ${grid_js_id}.setStructure(picklistLayout);
- ${grid_js_id}.setModel(model);
-
- dojo.connect(gridDom, "onRowClick",
- function(evt) {
- openils.acq.Lineitems.loadGrid(
- lineItemGrid, model.getRow(evt.rowIndex).id, lineitemLayout);
- });
- ${grid_js_id}.update();
- }
- </script>
+ <div id="${domprefix + '-container'}"
+ dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
+ <div structure='JUBGrid.jubGridLayout' jsid='${grid_jsid}'
+ dojoType='dojox.Grid' id="${domprefix + '-JUB-grid'}"> </div>
</div>
- <div dojoType="dijit.layout.ContentPane" sizeMin="20"
- sizeShare="50">
- <div jsid="lineItemGrid" dojoType="dojox.Grid"
- id=${domprefix + "-details-grid"}>
- <!-- Copy order details go here -->
- </div>
+ <div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
+ <div structure='JUBGrid.jubDetailGridLayout' jsid="JUBGrid.jubDetailGrid" dojoType="dojox.Grid"
+ id='${domprefix + "-details-grid"}'>
+ </div>
</div>
</div>
</%def>
More information about the open-ils-commits
mailing list