From 555ae14e7bf63b39e79cf17c81a765cc2336918e Mon Sep 17 00:00:00 2001 From: pines Date: Thu, 14 Sep 2006 19:55:57 +0000 Subject: [PATCH] deprecate some code and make checkin async to mitigate possible "white screen" git-svn-id: svn://svn.open-ils.org/ILS/trunk@6111 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/circ/checkin.js | 47 ++++++++-- Open-ILS/xul/staff_client/server/circ/util.js | 104 ++++++++++------------- 2 files changed, 85 insertions(+), 66 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index 13faadea27..0d71b652d6 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -259,9 +259,41 @@ circ.checkin.prototype = { var auto_print = document.getElementById('checkin_auto'); if (auto_print) auto_print = auto_print.checked; JSAN.use('circ.util'); - var checkin = circ.util.checkin_via_barcode( - ses(), barcode, backdate, auto_print + circ.util.checkin_via_barcode( + ses(), barcode, backdate, auto_print, { + 'disable_textbox' : function() { + obj.controller.view.checkin_barcode_entry_textbox.disabled = true; + obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'true'); + }, + 'enable_textbox' : function() { + obj.controller.view.checkin_barcode_entry_textbox.disabled = false; + obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); + }, + 'checkin_result' : function(checkin) { + obj.controller.view.checkin_barcode_entry_textbox.disabled = false; + obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); + obj.checkin2(checkin,backdate); + } + } ); + } catch(E) { + obj.error.standard_unexpected_error_alert('Something went wrong in circ.util.checkin: ',E); + if (typeof obj.on_failure == 'function') { + obj.on_failure(E); + } + if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') { + obj.error.sdump('D_CIRC','circ.util.checkin: Calling external .on_failure()\n'); + window.xulG.on_failure(E); + } else { + obj.error.sdump('D_CIRC','circ.util.checkin: No external .on_failure()\n'); + } + } + + }, + + 'checkin2' : function(checkin,backdate) { + var obj = this; + try { if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */ if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */ || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */ @@ -303,27 +335,32 @@ circ.checkin.prototype = { obj.error.sdump('D_CIRC','circ.checkin: No external .on_checkin()\n'); } + return true; + } catch(E) { - obj.error.standard_unexpected_error_alert('Something went wrong in circ.checkin.checkin: ',E); + obj.error.standard_unexpected_error_alert('Something went wrong in circ.util.checkin2: ',E); if (typeof obj.on_failure == 'function') { obj.on_failure(E); } if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') { - obj.error.sdump('D_CIRC','circ.checkin: Calling external .on_failure()\n'); + obj.error.sdump('D_CIRC','circ.util.checkin2: Calling external .on_failure()\n'); window.xulG.on_failure(E); } else { - obj.error.sdump('D_CIRC','circ.checkin: No external .on_failure()\n'); + obj.error.sdump('D_CIRC','circ.util.checkin2: No external .on_failure()\n'); } } }, 'on_checkin' : function() { + this.controller.view.checkin_barcode_entry_textbox.disabled = false; + this.controller.view.checkin_barcode_entry_textbox.select(); this.controller.view.checkin_barcode_entry_textbox.value = ''; this.controller.view.checkin_barcode_entry_textbox.focus(); }, 'on_failure' : function() { + this.controller.view.checkin_barcode_entry_textbox.disabled = false; this.controller.view.checkin_barcode_entry_textbox.select(); this.controller.view.checkin_barcode_entry_textbox.focus(); }, diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 39b727ce42..d3c017d5e7 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -5,7 +5,7 @@ circ.util = {}; circ.util.EXPORT_OK = [ 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns', - 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_via_copy_barcode', + 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', 'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode', ]; circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK }; @@ -909,22 +909,41 @@ circ.util.std_map_row_to_column = function(error_value) { } } -circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print) { +circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print,async) { try { JSAN.use('util.error'); var error = new util.error(); JSAN.use('util.network'); var network = new util.network(); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); JSAN.use('util.date'); + if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null; var params = { 'barcode' : barcode }; if (backdate) params.backdate = backdate; + if (typeof async == 'object') { + try { async.disable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; + } var check = network.request( api.CHECKIN_VIA_BARCODE.app, api.CHECKIN_VIA_BARCODE.method, [ session, params ], - null, + async ? function(req) { + try { + var check = req.getResultObject(); + var r = circ.util.checkin_via_barcode2(session,barcode,backdate,auto_print,check); + if (typeof async == 'object') { + try { async.checkin_result(r); } catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); }; + } + } catch(E) { + JSAN.use('util.error'); var error = new util.error(); + error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E); + if (typeof async == 'object') { + try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; + } + return null; + } + } : null, { 'title' : 'Override Checkin Failure?', 'overridable_events' : [ @@ -949,6 +968,27 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print) { } } ); + if (!async) { + return circ.util.checkin_via_barcode2(session,barcode,backdate,auto_print,check); + } + + + } catch(E) { + JSAN.use('util.error'); var error = new util.error(); + error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E); + if (typeof async == 'object') { + try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; + } + return null; + } +} + +circ.util.checkin_via_barcode2 = function(session,barcode,backdate,auto_print,check) { + try { + JSAN.use('util.error'); var error = new util.error(); + JSAN.use('util.network'); var network = new util.network(); + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + JSAN.use('util.date'); error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) ); @@ -1131,35 +1171,6 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print) { } -// case '2': case 2: /* LOST??? */ -// JSAN.use('patron.util'); -// var au_obj = patron.util.retrieve_au_via_id( session, check.circ.usr() ); -// var msg = check.text + '\r\n' + 'Barcode: ' + barcode + ' Title: ' + -// check.record.title() + ' Author: ' + check.record.author() + '\r\n' + -// 'Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + -// au_obj.first_given_name(); -// var pcheck = error.yns_alert( -// msg, -// 'Lost Item', -// 'Edit Copy & Patron', -// "Just Continue", -// null, -// "Check here to confirm this message" -// ); -// if (pcheck == 0) { -// //FIXME//Re-implement -// /* -// var w = mw.spawn_main(); -// setTimeout( -// function() { -// mw.spawn_patron_display(w.document,'new_tab','main_tabbox',{'patron':au_obj}); -// mw.spawn_batch_copy_editor(w.document,'new_tab','main_tabbox', -// {'copy_ids':[ check.copy.id() ]}); -// }, 0 -// ); -// */ -// } -// break; return check; } catch(E) { JSAN.use('util.error'); var error = new util.error(); @@ -1168,35 +1179,6 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print) { } } -circ.util.hold_capture_via_copy_barcode = function ( session, barcode, retrieve_flag ) { - try { - JSAN.use('util.network'); var network = new util.network(); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var params = { barcode: barcode } - if (retrieve_flag) { params.flesh_record = retrieve_flag; params.flesh_copy = retrieve_flag; } - var robj = network.request( - api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.app, - api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.method, - [ session, params ] - ); - var check = robj.payload; - if (!check) { - check = {}; - check.status = robj.ilsevent; - check.copy = new acp(); check.copy.barcode( barcode ); - } - check.text = robj.textcode; - check.route_to = robj.route_to; - //check.text = 'Captured for Hold'; - if (Number(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname(); - return check; - } catch(E) { - JSAN.use('util.error'); var error = new util.error(); - error.standard_unexpected_error_alert('Hold Capture Failed',E); - return null; - } -} - circ.util.renew_via_barcode = function ( barcode, patron_id ) { try { var obj = {}; -- 2.11.0