[open-ils-commits] r10107 - in
branches/acq-experiment/Open-ILS/web: js/dojo/openils/acq
oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jul 23 23:13:50 EDT 2008
Author: erickson
Date: 2008-07-23 23:13:43 -0400 (Wed, 23 Jul 2008)
New Revision: 10107
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/common/jubgrid.js
Log:
added virtualFields for estimated and actual price during jubgrid build (at least from the picklsit perspective). added logic to update those attrs and re-render the values in the grid
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-07-23 20:36:51 UTC (rev 10106)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-07-24 03:13:43 UTC (rev 10107)
@@ -40,7 +40,7 @@
pl_this._items.push(data);
}
- storeData = jub.toStoreData(pl_this._items);
+ storeData = jub.toStoreData(pl_this._items, null, {virtualFields:['estimated_price', 'actual_price']});
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,
@@ -107,6 +107,33 @@
}
};
+ var self = this;
+ // after an attribute has been updated
+ var attrUpdateDone = function(r, attr) {
+ var res = r.recv().content();
+ if(e = openils.Event.parse(res))
+ return alert(e);
+ var oldVal = new openils.acq.Lineitems(
+ {lineitem:item}).findAttr(attr, 'lineitem_local_attr_definition');
+ if(oldVal) {
+ // if this attr already exists on the object, just update the value
+ for(var i = 0; i < item.attributes().length; i++) {
+ var attrobj = item.attributes()[i];
+ if(attrobj.attr_type() == 'lineitem_local_attr_definition' && attrobj.attr_name() == attr) {
+ attrobj.attr_value(newVal);
+ }
+ }
+ } else {
+ // if this is a new attribute, create a new object to match reality
+ liad = new acqlia();
+ liad.attr_type('lineitem_local_attr_definition');
+ liad.attr_value(newVal);
+ liad.attr_name(attr);
+ liad.id(res);
+ item.attributes().push(liad);
+ }
+ }
+
if (oldVal == newVal) {
return;
}
@@ -116,6 +143,14 @@
if(newVal == '')
newVal = null;
item.provider(newVal);
+ } else if(attr == 'estimated_price' || attr == 'actual_price') {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem_local_attr.set'],
+ { async: true,
+ params: [openils.User.authtoken, item.id(), attr, newVal],
+ oncomplete: function(r) {attrUpdateDone(r, attr); }
+ }
+ );
} else {
//alert("Unexpected attr in Picklist.onSet: '"+attr+"'");
return;
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-07-23 20:36:51 UTC (rev 10106)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-07-24 03:13:43 UTC (rev 10107)
@@ -107,7 +107,6 @@
for (var i in lineitems) {
JUBGrid.lineitems[lineitems[i].id()] = lineitems[i];
}
- dojo.connect (gridWidget, "onApplyCellEdit", JUBGrid.gridDataChanged);
JUBGrid.jubGrid = gridWidget;
JUBGrid.jubGrid.setModel(model);
if(JUBGrid.showDetails) {
More information about the open-ils-commits
mailing list