[open-ils-commits] r9682 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils/acq
oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common
oilsweb/oilsweb/templates/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu May 22 20:27:23 EDT 2008
Author: djfiander
Date: 2008-05-22 20:27:22 -0400 (Thu, 22 May 2008)
New Revision: 9682
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
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/templates/oils/default/common/jubgrid.html
Log:
Can now delete lineitem detail records from a lineitem in a picklist
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-23 00:23:25 UTC (rev 9681)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js 2008-05-23 00:27:22 UTC (rev 9682)
@@ -85,32 +85,26 @@
});
};
-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);
+ if (attr == "fund") {
+ item.fund(newVal);
+ } else {
+ alert("Unexpected attr in Lineitems.alertOnSet: '"+attr+"'");
+ return;
+ }
+
fieldmapper.standardRequest(
["open-ils.acq", "open-ils.acq.lineitem_detail.update"],
{ params: [openils.User.authtoken, item],
@@ -118,6 +112,19 @@
});
};
+openils.acq.Lineitems.deleteLID = function(id, onComplete) {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem_detail.delete'],
+ { async: true,
+ params: [openils.User.authtoken, id],
+ oncomplete: function(r) {
+ msg = r.recv()
+ stat = msg.content();
+ onComplete();
+ }
+ });
+};
+
openils.acq.Lineitems.loadGrid = function(domNode, id, layout) {
if (!openils.acq.Lineitems.ModelCache[id]) {
openils.acq.Lineitems.createStore(id,
@@ -126,7 +133,8 @@
var model = new dojox.grid.data.DojoData(null, store,
{rowsPerPage: 20, clientSort:true, query:{id:'*'}});
- dojo.connect(store, "onSet", openils.acq.Lineitems.alertOnSet);
+ dojo.connect(store, "onSet",
+ openils.acq.Lineitems.alertOnSet);
openils.acq.Lineitems.ModelCache[id] = model;
domNode.setStructure(layout);
@@ -138,6 +146,4 @@
domNode.update();
}
};
-
-
}
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-05-23 00:23:25 UTC (rev 9681)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-05-23 00:27:22 UTC (rev 9682)
@@ -47,9 +47,9 @@
var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex);
if (!data || !data.fund) return;
try {
- return openils.acq.Fund.retrieve(data.fund).name();
+ return openils.acq.Fund.retrieve(data.fund).name();
} catch (evt) {
- return data.fund;
+ return data.fund;
}
},
getLIDLibName : function(rowIndex) {
@@ -63,10 +63,42 @@
JUBGrid.jubGrid.setModel(model);
dojo.connect(gridWidget, "onRowClick",
function(evt) {
- openils.acq.Lineitems.loadGrid(
- JUBGrid.jubDetailGrid,
+ JUBGrid.jubDetailGrid.lineitemID = model.getRow(evt.rowIndex).id;
+ openils.acq.Lineitems.loadGrid(
+ JUBGrid.jubDetailGrid,
JUBGrid.jubGrid.model.getRow(evt.rowIndex).id, JUBGrid.jubDetailGridLayout);
});
gridWidget.update();
- }
+ },
+ deleteLID: function(evt) {
+ var list =[];
+ var selected = JUBGrid.jubDetailGrid.selection.getSelected();
+ for (var idx = 0; idx < selected.length; idx++) {
+ var rowIdx = selected[idx];
+ var lid = JUBGrid.jubDetailGrid.model.getRow(rowIdx);
+ var deleteFromStore = function () {
+ var deleteItem = function(item, rq) {
+ JUBGrid.jubDetailGrid.model.store.deleteItem(item);
+ };
+ JUBGrid.jubDetailGrid.model.store.fetch({query:{id:lid.id},
+ onItem: deleteItem});
+ };
+
+ openils.acq.Lineitems.deleteLID(lid.id, deleteFromStore);
+ JUBGrid.jubDetailGrid.update();
+
+ var updateCount = function(item) {
+ var newval = JUBGrid.jubGrid.model.store.getValue(item, "item_count");
+ JUBGrid.jubGrid.model.store.setValue(item, "item_count", newval-1);
+ JubGrid.jubGrid.update();
+ };
+
+ JUBGrid.jubGrid.model.store.fetch({query:{id:JUBGrid.jubDetailGrid.lineitemID},
+ onItem: updateCount});
+ }
+ },
+ createLID: function(evt) {
+ console.dir(evt);
+ },
};
+
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-23 00:23:25 UTC (rev 9681)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html 2008-05-23 00:27:22 UTC (rev 9682)
@@ -10,11 +10,11 @@
HTML where you want the display to appear:
<%namespace file='/oils/default/common/jubgrid.html' name='jubgrid'/>
- ${jubgrid.jubgrid('dom_prefix', 'grid_js_id')}
+ ${jubgrid.jubgrid('dom_prefix', 'grid_jsid')}
where 'dom_prefix' is a string that will be used as the prefix
for the DOM notes that are created by this template, and
-'grid_js_id' is a valid JavaScript identifier that will name the
+'grid_jsid' is a valid JavaScript identifier that will name the
DOM node to which the list of JUBs will be attached. For example
${jubgrid.jubgrid('oils-acq-picklist', 'pickListGrid')}
@@ -29,9 +29,9 @@
To fill the grid with data, call the javascript function
- populateJUBGrid(grid_js_id, model)
+ populateJUBGrid(grid_jsid, model)
-'grid_js_id' is the same javascript id that was used to
+'grid_jsid' is the same javascript id that was used to
instantiate the template, and model is a javascript variable
pointing to the JUB model (and store) that you have created.
@@ -42,7 +42,7 @@
activeSizing="1" layoutAlign="client">
<script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/common/jubgrid.js'> </script>
- <script>
+ <script type="text/javascript">
JUBGrid.jubGridLayout = [{
cells: [[
{name: "ID", field: 'id'},
@@ -74,6 +74,16 @@
dojoType='dojox.Grid' id="${domprefix + '-JUB-grid'}"> </div>
</div>
<div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
+ <div jsid="lineItemButtonbar" dojoType="dijit.layout.ContentPane"
+ id=${domprefix+"-details-buttonbar"}>
+ <button dojoType='dijit.form.Button'
+ onclick='JUBGrid.createLID'>
+ ${_('Add Copy')}
+ </button>
+ <button dojotype='dijit.form.Button' onclick='JUBGrid.deleteLID'>
+ ${_('Delete Selected Copy')}
+ </button>
+ </div>
<div structure='JUBGrid.jubDetailGridLayout' jsid="JUBGrid.jubDetailGrid" dojoType="dojox.Grid"
id='${domprefix + "-details-grid"}'>
</div>
More information about the open-ils-commits
mailing list