[open-ils-commits] SPAM: r9598 - in
branches/acq-experiment/Open-ILS/web: js/dojo/openils/acq
oilsweb/oilsweb/controllers/acq
oilsweb/oilsweb/templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue May 13 22:50:39 EDT 2008
Author: djfiander
Date: 2008-05-13 22:50:37 -0400 (Tue, 13 May 2008)
New Revision: 9598
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html
Log:
Move all server interaction into the Javascript
Use new object-oriented openils.acq.Picklist
Can now edit funds on lineitem_details
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js 2008-05-14 02:47:07 UTC (rev 9597)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js 2008-05-14 02:50:37 UTC (rev 9598)
@@ -18,12 +18,18 @@
dojo._hasResource['openils.acq.Lineitems'] = true;
dojo.provide('openils.acq.Lineitems');
+dojo.require('dojo.data.ItemFileWriteStore');
+dojo.require('dojox.grid.Grid');
+dojo.require('dojox.grid._data.model');
+dojo.require('fieldmapper.dojoData');
+
/** Declare the Lineitems class with dojo */
dojo.declare('openils.acq.Lineitems', null, {
/* add instance methods here if necessary */
});
-openils.acq.Lineitems.cache = {};
+openils.acq.Lineitems.ModelCache = {};
+openils.acq.Lineitems.acqlidCache = {};
openils.acq.Lineitems.createStore = function(li_id, onComplete) {
// Fetches the details of a lineitem and builds a grid
@@ -33,12 +39,12 @@
var items = [];
while (msg = r.recv()) {
var data = msg.content();
- alert(js2JSON(data));
for (i in data.lineitem_details()) {
- items.push(data.lineitem_details()[i]);
+ var lid = data.lineitem_details()[i];
+ items.push(lid);
+ openils.acq.Lineitems.acqlidCache[lid.id()] = lid;
}
}
- openils.acq.Lineitems.cache[li_id] = items;
onComplete(acqlid.toStoreData(items));
}
@@ -52,74 +58,58 @@
});
};
+openils.acq.Lineitems.obj2Str = function(obj) {
+ var str = "";
+ for (var prop in item) {
+ str += prop + " = " + item[prop] + "\n";
+ }
+ return(str);
+}
+
+openils.acq.Lineitems.alertOnSet = function(griditem, attr, oldVal, newVal) {
+ var item;
+ var updateDone = function(r) {
+ var stat = r.recv().content();
+ // XXX Check for Event
+// alert("updateDone");
+ }
+ if (oldVal == newVal) {
+// alert("value edited, but not changed. skipping");
+ return;
+ }
+
+ console.dir(griditem);
+ item = openils.acq.Lineitems.acqlidCache[griditem.id];
+
+// console.log("alertOnSet: newVal = "+newVal);
+// console.dir(item)
+ item.fund(newVal);
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.lineitem_detail.update"],
+ { params: [openils.User.authtoken, item],
+ oncomplete: updateDone
+ });
+};
+
openils.acq.Lineitems.loadGrid = function(domNode, id, layout) {
- if (!openils.acq.Lineitems.cache[id]) {
+ if (!openils.acq.Lineitems.ModelCache[id]) {
openils.acq.Lineitems.createStore(id,
function(storeData) {
- var store = new dojo.data.ItemFileReadStore({data:storeData});
+ var store = new dojo.data.ItemFileWriteStore({data:storeData});
var model = new dojox.grid.data.DojoData(null, store,
{rowsPerPage: 20, clientSort:true, query:{id:'*'}});
- openils.acq.Lineitems.cache[id] = model;
+ dojo.connect(store, "onSet", openils.acq.Lineitems.alertOnSet);
+ openils.acq.Lineitems.ModelCache[id] = model;
+
domNode.setStructure(layout);
domNode.setModel(model);
domNode.update();
- alert('ouch! update');
});
} else {
- domNode.setModel(openils.acq.Lineitems.cache[id]);
+ domNode.setModel(openils.acq.Lineitems.ModelCache[id]);
domNode.update();
}
-}
+};
-// openils.acq.Lineitems.initGrid = function(domId, columns) {
-// var store = new dojo.data.ItemFileWriteStore({data:{identify:'id'}});
-// var model = new dojox.grid.data.DojoData(null, store,
-// {rowsPerPage: 20, clientSort: true});
-
-// var domNode = dojo.byId(domId);
-// var columns = layout.cells;
-// var colWidth = (dojo.coords(domNode.parentNode).w / columns.length) - 30;
-// for(var i in columns) {
-// if(columns[i].width == undefined)
-// columns[i].width = colWidth + 'px';
-// }
-
-
-// var grid = new dojox.Grid({structure: layout}, domId);
-
-// openils.acq.Lineitems.loadGrid = function(domId, li_id) {
-// var ses = new OpenSRF.ClientSession('open-ils.acq');
-// var req = ses.request('open-ils.acq.lineitem.retrieve',
-// openils.User.authtoken, li_id, {flesh_attrs:1,flesh_li_details:1});
-
-// req.oncomplete = function(r) {
-// var msg;
-// grid.setModel(gridRefs.model);
-// model.query = {id:'*'};
-
-// while (msg = r.recv()) {
-// var li = msg.content();
-
-// for (i in li.lineitem_details()) {
-// lid = li.lineitem_details()[i]
-
-// alert(js2JSON(lid));
-
-// store.newItem({
-// id:lid.id(),
-// fund:lid.fund(),
-// location:lid.location(),
-// });
-// }
-// }
-// grid.update();
-// };
-
-// req.send();
-// };
-
-// return grid;
-// };
-
}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-05-14 02:47:07 UTC (rev 9597)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-05-14 02:50:37 UTC (rev 9598)
@@ -20,15 +20,7 @@
def view(self, **kwargs):
r = RequestMgr()
- pl_manager = oilsweb.lib.acq.picklist.PicklistMgr(r, picklist_id=kwargs['id'])
- pl_manager.retrieve()
- pl_manager.retrieve_lineitems(flesh_provider=True,
- sort_attr="author",
- sort_dir="asc",
- offset=r.ctx.acq.offset.value,
- limit=r.ctx.acq.limit.value)
- r.ctx.acq.picklist.value = pl_manager.picklist
- r.ctx.acq.picklist_list.value = pl_manager.retrieve_list()
+ r.ctx.acq.picklist.value = kwargs['id']
return r.render('acq/picklist/view.html')
def create(self, **kwargs):
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-14 02:47:07 UTC (rev 9597)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html 2008-05-14 02:50:37 UTC (rev 9598)
@@ -3,30 +3,32 @@
vim:ts=4:sw=4:et:ft=mako:
-->
<%inherit file='../base.html'/>
-<%namespace file='../../common/widgets.html' name='widget' />
-<%namespace file='picklist_summary.html' name='picklist' />
<%def name="block_js()">
${parent.block_js()}
-
<script type="text/javascript">
+ dojo.require('dojo.data.ItemFileReadStore');
dojo.require("dijit.layout.SplitContainer")
+ dojo.require('dijit.layout.LayoutContainer');
+ dojo.require('dijit.layout.ContentPane');
+ dojo.require('dijit.layout.SplitContainer');
+ dojo.require('dojox.grid.Grid');
dojo.require('openils.acq.Picklist');
- // For decoding fund IDs into names
dojo.require("openils.acq.Fund");
- // For decoding Library IDs into names
+ dojo.require("openils.acq.Lineitems");
+ dojo.require("openils.widget.FundSelector");
dojo.require("fieldmapper.OrgUtils");
- </script>
- <script type='text/javascript'>
+
+ var globalUser = new openils.User();
function getJUBTitle(rowIndex) {
var data = pickListGrid.model.getRow(rowIndex);
if (!data) return '';
- return openils.acq.Picklist.find_attr(data.id, "title", "lineitem_marc_attr_definition")
+ return plist.find_attr(data.id, "title", "lineitem_marc_attr_definition")
}
function getJUBPrice(rowIndex) {
var data = pickListGrid.model.getRow(rowIndex);
if (!data) return;
- return openils.acq.Picklist.find_attr(data.id, "price", "lineitem_marc_attr_definition")
+ return plist.find_attr(data.id, "price", "lineitem_marc_attr_definition")
}
function getLIDFundName(rowIndex) {
var data = lineItemGrid.model.getRow(rowIndex);
@@ -52,24 +54,26 @@
<%def name="block_content()">
<div dojoType="dijit.layout.LayoutContainer" style="height:100%">
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
- ${picklist.summary(c.oils.acq.picklist.value)}
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" jsId="pl_header">
+ <div id='oils-acq-picklist-header'>
+ ${_('Picklist')}
+ <span id='oils-acq-picklist-name'> </span>
+ <div class='oils-acq-picklist-attributes'>
+ <div>Create
+ date: <span id="oils-acq-picklist-attr-cdate"></span></div>
+ <div>Last updated: <span id="oils-acq-picklist-attr-edate"></span></div>
+ <div>Selector: <span id="oils-acq-picklist-attr-owner"></span></div>
+ </div>
+ </div>
</div>
<div dojoType="dijit.layout.SplitContainer"
orientation="vertical" sizerWidth="5"
activeSizing="1" layoutAlign="client">
<div id="oils-acq.picklist-container"
- dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="20">
+ dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
<div jsid='pickListGrid' dojoType='dojox.Grid'
id="oils-acq-picklist-grid"> </div>
- <script type="text/javascript" src="/js/dojo/openils/acq/Lineitems.js"></script>
- <script type="text/javascript" src="/js/dojo/openils/widget/FundSelector.js"></script>
<script type="text/javascript">
- dojo.require("openils.acq.Picklist");
- dojo.require("openils.acq.Lineitems");
-// dojo.require("openils.widget.FundSelector");
- dojo.require('dojo.data.ItemFileReadStore');
-
var picklistLayout = [{
cells: [[
{name: "ID", field: 'id'},
@@ -80,34 +84,38 @@
]]
}];
- var lineitemLayout = [{ cells: [[
- {name:"ID", field:"id"},
- {name:"Fund", field:"fund",
- editor: openils.widget.FundSelector,
- get:getLIDFundName},
- {name:"Location", get:getLIDLibName} ]] }];
-
- 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(picklistLayout);
+ var lineitemLayout = [{
+ cells: [[
+ {name:"ID", field:"id"},
+ {name:"Fund", field:"fund",
+ get:getLIDFundName,
+ editor: openils.widget.FundSelector,
+ },
+ {name:"Location", field:"location",
+ get:getLIDLibName}
+ ]]
+ }];
+ var plist = new openils.acq.Picklist(${c.oils.acq.picklist.value},
+ function(model) {
+ pickListGrid.setStructure(picklistLayout);
pickListGrid.setModel(model);
- pickListGrid.onRowClick = function(evt) {
+ dojo.connect(pickListGrid, "onRowClick", function(evt) {
openils.acq.Lineitems.loadGrid(lineItemGrid,
model.getRow(evt.rowIndex).id,
lineitemLayout);
- };
+ });
+ dojo.byId("oils-acq-picklist-name").innerHTML = plist.name();
+ 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();
pickListGrid.update();
});
</script>
</div>
<div dojoType="dijit.layout.ContentPane" sizeMin="20"
- sizeShare="80">
+ sizeShare="50">
<div jsid="lineItemGrid" dojoType="dojox.Grid" id="oils-acq-picklist-details-grid">
<!-- Copy order details go here -->
</div>
@@ -115,3 +123,6 @@
</div>
</div>
</%def>
+<!-- Local Variables: -->
+<!-- mmm-classes: html-js -->
+<!-- End: -->
More information about the open-ils-commits
mailing list