[open-ils-commits] r10460 -
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 27 10:13:24 EDT 2008
Author: erickson
Date: 2008-08-27 10:13:21 -0400 (Wed, 27 Aug 2008)
New Revision: 10460
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
Log:
move the approval callback to external function because JS will overwrite closure vars within a loop
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-08-26 21:39:36 UTC (rev 10459)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-08-27 14:13:21 UTC (rev 10460)
@@ -144,41 +144,40 @@
},
approveJUB: function(evt) {
- var list = [];
- var selected = JUBGrid.jubGrid.selection.getSelected();
+ var list = [];
+ var selected = JUBGrid.jubGrid.selection.getSelected();
+ for (var idx = 0; idx < selected.length; idx++) {
+ var rowIdx = selected[idx];
+ JUBGrid.approveSingleJUB(JUBGrid.jubGrid.model.getRow(rowIdx));
+ }
+ },
- for (var idx = 0; idx < selected.length; idx++) {
- var rowIdx = selected[idx];
- var jub = JUBGrid.jubGrid.model.getRow(rowIdx);
- var li = new openils.acq.Lineitem({lineitem:JUBGrid.getLi(jub.id)});
- var approveStore = function(evt) {
- if (evt) {
- // something bad happened
- console.log("jubgrid.js: approveJUB: error:");
- console.dir(evt);
- alert("Error: "+evt.desc);
- } else {
- var approveACQLI = function(jub, rq) {
- JUBGrid.jubGrid.model.store.setValue(jub,
- "state",
- "approved");
- JUBGrid.jubGrid.update();
- // Reload lineitem details, read-only
- openils.acq.Lineitem.loadLIDGrid(
- JUBGrid.jubDetailGrid, li.id(),
- JUBGrid.jubDetailGridLayout);
- //JUBGrid.jubDetailGridLayoutReadOnly);
- };
+ approveSingleJUB: function(jub) {
+ var li = new openils.acq.Lineitem({lineitem:JUBGrid.getLi(jub.id)});
+ var approveStore = function(evt) {
+ if (evt) {
+ // something bad happened
+ console.log("jubgrid.js: approveJUB: error:");
+ console.dir(evt);
+ alert("Error: "+evt.desc);
+ } else {
+ var approveACQLI = function(jub, rq) {
+ alert('setting jub to approved ' + jub.id);
+ JUBGrid.jubGrid.model.store.setValue(jub, "state", "approved");
+ JUBGrid.jubGrid.model.refresh();
+ JUBGrid.jubGrid.update();
+ // Reload lineitem details, read-only
+ //openils.acq.Lineitem.loadLIDGrid(JUBGrid.jubDetailGrid, li.id(), JUBGrid.jubDetailGridLayout);
+ //JUBGrid.jubDetailGridLayoutReadOnly);
+ };
+ JUBGrid.jubGrid.model.store.fetch({query:{id:jub.id}, onItem: approveACQLI});
+ }
+ };
- JUBGrid.jubGrid.model.store.fetch({query:{id:jub.id},
- onItem: approveACQLI});
- }
- };
-
- li.approve(approveStore);
- }
+ li.approve(approveStore);
},
+
removeSelectedJUBs: function(evt) {
function deleteList(list, idx, oncomplete) {
More information about the open-ils-commits
mailing list