From: phasefx Date: Thu, 22 Jan 2009 20:51:57 +0000 (+0000) Subject: refactor checkin to fix audibles coming after dialogs instead of before. The checkin... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=431a4207a2ce96e865dff26e5c15daec720d8fc4;p=Evergreen.git refactor checkin to fix audibles coming after dialogs instead of before. The checkin code for the main checkin interface was effectively asynchronous; sound and dialogs appear to misbehave when in asynchronous callbacks git-svn-id: svn://svn.open-ils.org/ILS/trunk@11917 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index eea1222cfd..dd96475532 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -301,8 +301,10 @@ circ.checkin.prototype = { if (auto_print) auto_print = auto_print.checked; JSAN.use('circ.util'); circ.util.checkin_via_barcode( - ses(), { 'barcode' : barcode }, backdate, auto_print, { - 'disable_textbox' : function() { + ses(), + { + 'barcode' : barcode, + 'disable_textbox' : function() { obj.controller.view.checkin_barcode_entry_textbox.disabled = true; obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'true'); }, @@ -315,7 +317,9 @@ circ.checkin.prototype = { obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); obj.checkin2(checkin,backdate); } - } + }, + backdate, + auto_print ); } catch(E) { obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.exception', [E])); diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index cac4bac084..21672b1737 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -1871,39 +1871,44 @@ circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,asyn 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'); + JSAN.use('util.date'); JSAN.use('util.functional'); if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null; //var params = { 'barcode' : barcode }; if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}'); - if (typeof async == 'object') { - try { async.disable_textbox(); } - catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; + if (typeof params.disable_textbox == 'function') { + try { params.disable_textbox(); } + catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); }; } + + function checkin_callback(req) { + try { + var check = req.getResultObject(); + var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check); + if (typeof params.checkin_result == 'function') { + try { params.checkin_result(r); } + catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); }; + } + if (typeof async == 'function') async(check); + return check; + } catch(E) { + JSAN.use('util.error'); var error = new util.error(); + error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E); + if (typeof params.enable_textbox == 'function') { + try { params.enable_textbox(); } + catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); }; + } + return null; + } + } + var check = network.request( api.CHECKIN_VIA_BARCODE.app, api.CHECKIN_VIA_BARCODE.method, - [ session, params ], - async ? function(req) { - try { - var check = req.getResultObject(); - var r = circ.util.checkin_via_barcode2(session,params,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(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E); - if (typeof async == 'object') { - try { async.enable_textbox(); } - catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; - } - return null; - } - } : null, + [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ], + async ? checkin_callback : null, { 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'), 'overridable_events' : [ @@ -1932,16 +1937,16 @@ circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,asyn } } ); - if (!async) { - return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check); + if (! async ) { + return checkin_callback( { 'getResultObject' : function() { return check; } } ); } } catch(E) { JSAN.use('util.error'); var error = new util.error(); error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E); - if (typeof async == 'object') { - try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); }; + if (typeof params.enable_textbox == 'function') { + try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); }; } return null; }