From 13455cd7f7a9ec77e843c00a1e644602bae28a79 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 28 Aug 2006 13:28:05 +0000 Subject: [PATCH] made hold possibility check async to prevent browser freeze on long queries git-svn-id: svn://svn.open-ils.org/ILS/trunk@5729 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/skin/default/js/holds.js | 42 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js index c4486c3407..c3df1fbcd8 100644 --- a/Open-ILS/web/opac/skin/default/js/holds.js +++ b/Open-ILS/web/opac/skin/default/js/holds.js @@ -532,14 +532,16 @@ function holdsSetSelectedFormats() { } -function holdsCheckPossibility(pickuplib) { +function holdsCheckPossibility(pickuplib, hold, recurse) { var rec = holdArgs.record; var type = holdArgs.type; var req = new Request(CHECK_HOLD_POSSIBLE, G.user.session, { titleid : rec, patronid : G.user.id(), depth : 0, pickup_lib : pickuplib } ); req.request.alertEvent = false; - req.send(true); - return req.result(); + req.request._hold = hold; + req.request._recurse = recurse; + req.callback(holdHandleCreateResponse); + req.send(); } @@ -644,7 +646,9 @@ function holdsPlaceHold(hold, recurse) { swapCanvas($('check_holds_box')); if( holdArgs.type == 'M' || holdArgs.type == 'T' ) { - var res = holdsCheckPossibility(hold.pickup_lib()); + var res = holdsCheckPossibility(hold.pickup_lib(), hold, recurse); + + /* if(!res || checkILSEvent(res) ) { if(!res) { alert($('hold_not_allowed').innerHTML); @@ -658,11 +662,38 @@ function holdsPlaceHold(hold, recurse) { swapCanvas($('holds_box')); return; } + */ + + } else { + holdCreateHold(recurse, hold); + } +} + + +function holdHandleCreateResponse(r) { + var res = r.getResultObject(); + if(!res || checkILSEvent(res) ) { + if(!res) { + alert($('hold_not_allowed').innerHTML); + } else { + if( res.textcode == 'PATRON_BARRED' ) { + alertId('hold_failed_patron_barred'); + } else { + alert($('hold_not_allowed').innerHTML); + } + } + swapCanvas($('holds_box')); + return; } + + alert(js2JSON(res)); + holdCreateHold(r._recurse, r._hold); +} + +function holdCreateHold( recurse, hold ) { var method = CREATE_HOLD; if(recurse) method = CREATE_HOLD_OVERRIDE; - var req = new Request( method, holdArgs.requestor.session, hold ); req.request.alertEvent = false; req.send(true); @@ -675,6 +706,7 @@ function holdsPlaceHold(hold, recurse) { runEvt('common', 'holdUpdated'); } + function holdProcessResult( hold, res, recurse ) { if( res == '1' ) { -- 2.43.2