From 78b93b1e79d4139b2aefd52ab827dc37ed3133e8 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 11 Mar 2013 15:27:30 -0400 Subject: [PATCH] skip xulG.get_barcode if no barcode completion For Check In and Check Out interfaces, skip the xulG.get_barcode call if there are no active Barcode Completion entries (under Admin->Local Administration-> Barcode Completion) at the time of the staff client login sequence. However, for Check Out, an exception is made if the "Load patron from Checkout" library setting is in effect, since that functionality depends on xulG.get_barcode. Signed-off-by: Jason Etheridge Signed-off-by: Thomas Berezansky --- .../staff_client/chrome/content/OpenILS/data.js | 21 +++++++++++ .../staff_client/chrome/content/main/constants.js | 1 + Open-ILS/xul/staff_client/server/circ/checkin.js | 16 ++++---- Open-ILS/xul/staff_client/server/circ/checkout.js | 44 ++++++++++++---------- 4 files changed, 56 insertions(+), 26 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index fc17229959..74c8793448 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -646,6 +646,27 @@ OpenILS.data.prototype = { this.chain.push( function() { var f = gen_fm_retrieval_func( + 'cbc', + [ + api.FM_CBC_PCRUD_SEARCH.app, + api.FM_CBC_PCRUD_SEARCH.method, + [ obj.session.key, {"active":"t"}, {"order_by":{"cbc":"id"}} ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( 'csp', [ api.FM_CSP_PCRUD_SEARCH.app, diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 3556c8c2fd..0956d9e4f8 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -223,6 +223,7 @@ var api = { 'FM_BRE_DELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.delete', 'secure' : false }, 'FM_BRE_UNDELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.undelete', 'secure' : false }, 'FM_BRN_FROM_MARCXML' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.marcxml_to_brn', 'secure' : false }, + 'FM_CBC_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.cbc.atomic', 'secure' : false }, 'FM_CBS_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.retrieve.cbs' }, 'FM_CBT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.billing_type.ranged.retrieve.all', 'secure' : false }, 'FM_CCS_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all', 'secure' : false }, diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index d628861ea3..c5cf940cf1 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -562,16 +562,18 @@ circ.checkin.prototype = { var async_checkbox = document.getElementById('async_checkin'); if (async_checkbox) { async = async_checkbox.getAttribute('checked') == 'true'; } var barcode = textbox.value; - // Auto-complete the barcode, items only - var barcode_object = xulG.get_barcode(window, 'asset', barcode); if (async) { textbox.value = ''; textbox.focus(); } - // user_false means the user selected "None of the above", abort before other prompts/errors - if(barcode_object == "user_false") return; - // Got a barcode without an error? Use it. Otherwise fall through. - if(barcode_object && typeof barcode_object.ilsevent == 'undefined') - barcode = barcode_object.barcode; + if (obj.data.list.cbc.length > 0) { // skip barcode completion lookups if none configured + // Auto-complete the barcode, items only + var barcode_object = xulG.get_barcode(window, 'asset', barcode); + // user_false means the user selected "None of the above", abort before other prompts/errors + if(barcode_object == "user_false") return; + // Got a barcode without an error? Use it. Otherwise fall through. + if(barcode_object && typeof barcode_object.ilsevent == 'undefined') + barcode = barcode_object.barcode; + } if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; } var placeholder_item = new acp(); placeholder_item.barcode( barcode ); diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index da375fe7d7..79c2cd17f1 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -610,26 +610,32 @@ circ.checkout.prototype = { if (! (params.barcode||params.noncat)) { return; } if (params.barcode) { - // Default is "just items" - var barcode_context = 'asset'; - // Add actor (can be any string that includes 'actor') if looking up patrons at checkout - if(String( obj.data.hash.aous['circ.staff_client.actor_on_checkout'] ) == 'true') - barcode_context += '-actor'; - // Auto-complete the barcode - var in_barcode = xulG.get_barcode(window, barcode_context, params.barcode); - // user_false is "None of the above selected", don't error out/fall through as they already said no - if(in_barcode == "user_false") return; - // We have a barcode and there was no error? - if(in_barcode && typeof in_barcode.ilsevent == 'undefined') { - // Check if it was an actor barcode (will never happen unless actor was added above) - if(in_barcode.type == 'actor') { - // Go to new patron (do not pass go, do not collect $200, do not prompt user) - var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true'; - var loc = xulG.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' ); - xulG.set_tab( loc, {}, { 'barcode' : in_barcode.barcode } ); - return; + var actor_on_checkout = String( + obj.data.hash.aous['circ.staff_client.actor_on_checkout'] + ) == 'true'; + // skip barcode completion lookups if we can + if (actor_on_checkout || obj.data.list.cbc.length > 0) { + // Default is "just items" + var barcode_context = 'asset'; + // Add actor (can be any string that includes 'actor') if looking up patrons at checkout + if(actor_on_checkout) + barcode_context += '-actor'; + // Auto-complete the barcode + var in_barcode = xulG.get_barcode(window, barcode_context, params.barcode); + // user_false is "None of the above selected", don't error out/fall through as they already said no + if(in_barcode == "user_false") return; + // We have a barcode and there was no error? + if(in_barcode && typeof in_barcode.ilsevent == 'undefined') { + // Check if it was an actor barcode (will never happen unless actor was added above) + if(in_barcode.type == 'actor') { + // Go to new patron (do not pass go, do not collect $200, do not prompt user) + var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true'; + var loc = xulG.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' ); + xulG.set_tab( loc, {}, { 'barcode' : in_barcode.barcode } ); + return; + } + params.barcode = in_barcode.barcode; } - params.barcode = in_barcode.barcode; } if ( obj.test_barcode(params.barcode) ) { /* good */ } else { /* bad */ return; } -- 2.11.0