[open-ils-commits] r7780 - trunk/Open-ILS/web/opac/skin/default/js
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Sep 14 11:04:53 EDT 2007
Author: erickson
Date: 2007-09-14 10:56:46 -0400 (Fri, 14 Sep 2007)
New Revision: 7780
Modified:
trunk/Open-ILS/web/opac/skin/default/js/myopac.js
Log:
made batch hold processing more generic. added support for batch hold thawing
Modified: trunk/Open-ILS/web/opac/skin/default/js/myopac.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2007-09-13 21:35:20 UTC (rev 7779)
+++ trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2007-09-14 14:56:46 UTC (rev 7780)
@@ -1303,7 +1303,9 @@
myOPACShowChecked();
}
+/** ---- batch hold processing ------------ */
+
/* myopac_holds_checkbx */
function myopacSelectAllHolds() {
var rows = getTableRows($("myopac_holds_tbody"));
@@ -1332,46 +1334,91 @@
return r;
}
-var myopacCancelledHolds = 0;
-var myopacTotalHoldsToCancel = 0;
+var myopacProcessedHolds = 0;
+var myopacTotalHoldsToProcess = 0;
function myopacDoHoldAction() {
- switch(getSelectorVal($('myopac_holds_actions'))) {
- case 'cancel':
- myopacBatchCancelHold();
- break;
+ var selectedRows = myopacSelectedHoldsRows();
+ action = getSelectorVal($('myopac_holds_actions'));
+ $('myopac_holds_actions_none').selected = true;
+ if(selectedRows.length == 0) return;
+
+ myopacProcessedHolds = 0;
+
+ if(!confirmId('myopac.holds.'+action+'.confirm')) return;
+
+ myopacSelectNoneHolds(); /* clear the selection */
+
+ /* first, let's collect the holds that actually need processing and
+ collect the full process count while we're at it */
+ var holds = [];
+ for(var i = 0; i < selectedRows.length; i++) {
+ hold = holdCache[myopacHoldIDFromRow(selectedRows[i])];
+ switch(action) {
+ case 'cancel':
+ holds.push(hold);
+ break;
+ case 'thaw':
+ if(isTrue(hold.frozen()))
+ holds.push(hold);
+ break;
+ case 'freeze':
+ if(!isTrue(hold.frozen()))
+ holds.push(hold);
+ break;
+ }
}
-}
+ myopacTotalHoldsToProcess = holds.length;
-function myopacBatchCancelHold() {
- if(!confirmId('myopac.holds.cancel.confirm')) return;
+ /* now we process them */
+ for(var i = 0; i < holds.length; i++) {
+ hold = holds[i];
+
+ var req;
+ switch(action) {
- myopacCancelledHolds = 0;
- var rows = myopacSelectedHoldsRows();
- myopacTotalHoldsToCancel = rows.length;
- if(myopacTotalHoldsToCancel == 0) return;
+ case 'cancel':
+ req = new Request(CANCEL_HOLD, G.user.session, hold.id());
+ break;
+
+ case 'thaw':
+ hold.frozen('f');
+ hold.thaw_date(null);
+ req = new Request(UPDATE_HOLD, G.user.session, hold);
+ break;
- unHideMe($('myopac_holds_processing'));
- hideMe($('myopac_holds_main_table'));
+ case 'freeze':
+ break;
+ }
- for(var i = 0; i < rows.length; i++) {
- var row = rows[i];
- id = row.id.replace(/.*_(\d+)$/, '$1');
- _debug("cancelling hold " + i);
- var req = new Request(CANCEL_HOLD, G.user.session, id);
- req.callback(myopacBatchCancelHoldCallback);
+ req.callback(myopacBatchHoldCallback);
req.send();
+ req = null;
}
}
-function myopacBatchCancelHoldCallback(r) {
+function myopacHoldIDFromRow(row) {
+ return row.id.replace(/.*_(\d+)$/, '$1');
+}
+
+function myopacShowHoldProcessing() {
+ unHideMe($('myopac_holds_processing'));
+ hideMe($('myopac_holds_main_table'));
+}
+
+function myopacHideHoldProcessing() {
+ hideMe($('myopac_holds_processing'));
+ unHideMe($('myopac_holds_main_table'));
+}
+
+function myopacBatchHoldCallback(r) {
r.getResultObject();
- if(++myopacCancelledHolds >= myopacTotalHoldsToCancel) {
- hideMe($('myopac_holds_processing'));
- unHideMe($('myopac_holds_main_table'));
+ if(++myopacProcessedHolds >= myopacTotalHoldsToProcess) {
+ myopacHideHoldProcessing();
holdCache = {};
myopacForceHoldsRedraw = true;
myOPACShowHolds();
}
}
+
More information about the open-ils-commits
mailing list