From: phasefx Date: Thu, 28 Oct 2010 21:19:48 +0000 (+0000) Subject: Put a placeholder row into the checkin list to better handle the async checkin option... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f04160443884098ec8980e6d8f68ba17277b68ad;p=evergreen%2Ftadl.git Put a placeholder row into the checkin list to better handle the async checkin option (so that items show up in the same order in which they were scanned; it also feels more responsive). This also forces us into a better way of handling errors: we keep the rows for such scans in the checkin list, but shove the error condition into the alert message field. These rows can't be acted upon with the Actions for Selected Items menu. git-svn-id: svn://svn.open-ils.org/ILS/trunk@18534 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 38c03eb117..c52d66f9c2 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -54,7 +54,25 @@ circ.checkin.prototype = { var sel = obj.list.retrieve_selection(); obj.selection_list = util.functional.map_list( sel, - function(o) { var p = JSON2js(o.getAttribute('retrieve_id')); p.unique_row_counter = o.getAttribute('unique_row_counter'); return p; } + function(o) { + if (o.getAttribute('retrieve_id')) { + try { + var p = JSON2js(o.getAttribute('retrieve_id')); + p.unique_row_counter = o.getAttribute('unique_row_counter'); + return p; + } catch(E) { + return -1; + } + } else { + return -1; + } + } + ); + obj.selection_list = util.functional.filter_list( + obj.selection_list, + function(o) { + return o != -1; + } ); obj.error.sdump('D_TRACE', 'circ/copy_status: selection list = ' + js2JSON(obj.selection_list) ); if (obj.selection_list.length == 0) { @@ -458,6 +476,19 @@ circ.checkin.prototype = { if (barcode) { if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; } } + var placeholder_item = new acp(); + placeholder_item.barcode( barcode ); + var row_params = obj.list.append( { + 'row' : { + 'my' : { + 'acp' : placeholder_item + } + }, + 'to_top' : true, + 'on_append' : function(rparams) { obj.row_map[ rparams.unique_row_counter ] = rparams; }, + 'on_remove' : function(unique_row_counter) { delete obj.row_map[ unique_row_counter ]; } + } ); + var backdate = obj.controller.view.checkin_effective_datepicker.value; var auto_print = document.getElementById('checkin_auto_print_slips'); if (auto_print) auto_print = auto_print.getAttribute('checked') == 'true'; @@ -477,7 +508,10 @@ circ.checkin.prototype = { 'checkin_result' : function(checkin) { textbox.disabled = false; //obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); - obj.checkin2(checkin,backdate); + obj.checkin2(checkin,backdate,row_params); + }, + 'info_blurb' : function(text) { + try { row_params.row.my.acp.alert_message( text ); } catch(E) {dump('error: ' + E + '\n');} } }; var suppress_holds_and_transits = document.getElementById('suppress_holds_and_transits'); @@ -508,10 +542,13 @@ circ.checkin.prototype = { }, - 'checkin2' : function(checkin,backdate) { + 'checkin2' : function(checkin,backdate,row_params) { var obj = this; try { - if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */ + if (!checkin) {/* circ.util.checkin used to be sole handler of errors and returns null currently */ + obj.list.refresh_row( row_params ); /* however, let's refresh the row because we're shoving error text into the dummy placeholder item's alert_message field */ + return obj.on_failure(); + } if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */ || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */ || checkin.ilsevent == -1 /* offline */ @@ -519,33 +556,30 @@ circ.checkin.prototype = { || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */ || checkin.ilsevent == 7009 /* CIRC_CLAIMS_RETURNED */ || checkin.ilsevent == 7011 /* COPY_STATUS_LOST */ - || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) return obj.on_failure(); + || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) { + obj.list.refresh_row( row_params ); + return obj.on_failure(); + } var retrieve_id = js2JSON( { 'circ_id' : checkin.circ ? checkin.circ.id() : null , 'copy_id' : checkin.copy.id(), 'barcode' : checkin.copy.barcode(), 'doc_id' : (typeof checkin.record != 'undefined' ? ( typeof checkin.record.ilsevent == 'undefined' ? checkin.record.doc_id() : null ) : null ) } ); if (checkin.circ && checkin.circ.checkin_time() == 'now') checkin.circ.checkin_time(backdate); if (document.getElementById('trim_list')) { var x = document.getElementById('trim_list'); if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; } } - obj.list.append( - { - 'retrieve_id' : retrieve_id, - 'row' : { - 'my' : { - 'circ' : checkin.circ, - 'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null, - 'mvr' : checkin.record, - 'acp' : checkin.copy, - 'au' : checkin.patron, - 'status' : checkin.status, - 'route_to' : checkin.route_to, - 'message' : checkin.message - } - }, - 'to_top' : true, - 'on_append' : function(rparams) { obj.row_map[ rparams.unique_row_counter ] = rparams; }, - 'on_remove' : function(unique_row_counter) { delete obj.row_map[ unique_row_counter ]; } + row_params['retrieve_id'] = retrieve_id; + row_params['row'] = { + 'my' : { + 'circ' : checkin.circ, + 'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null, + 'mvr' : checkin.record, + 'acp' : checkin.copy, + 'au' : checkin.patron, + 'status' : checkin.status, + 'route_to' : checkin.route_to, + 'message' : checkin.message } - ); + }; + obj.list.refresh_row( row_params ); obj.list.node.view.selection.select(0); JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good(); diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 0b5b56cf05..8cd554ae06 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -2473,8 +2473,12 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che check.what_happened = 'no_change'; if (document.getElementById('no_change_label')) { var m = document.getElementById('no_change_label').getAttribute('value'); - document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' '); + var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]); + document.getElementById('no_change_label').setAttribute('value', m + text + ' '); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( text ); + } } } if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) { @@ -2706,9 +2710,13 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che msg = ''; if (document.getElementById('no_change_label')) { var m = document.getElementById('no_change_label').getAttribute('value'); - m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]); + var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]); + m += text + ' '; document.getElementById('no_change_label').setAttribute('value', m); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( text ); + } } break; case 6: /* IN TRANSIT */ @@ -2741,6 +2749,9 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]); document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' '); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( needs_cat ); + } } break; case 15: // ON_RESERVATION_SHELF @@ -2819,9 +2830,13 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che msg = ''; if (document.getElementById('no_change_label')) { var m = document.getElementById('no_change_label').getAttribute('value'); - m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]); + var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]); + m += text + ' '; document.getElementById('no_change_label').setAttribute('value', m); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( text ); + } } break; default: @@ -3078,6 +3093,9 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]); document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' '); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( trans_msg ); + } } } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) { @@ -3103,6 +3121,9 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che var m = document.getElementById('no_change_label').getAttribute('value'); document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' '); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( mis_scan_msg ); + } } } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) { @@ -3200,6 +3221,9 @@ circ.util.renew_via_barcode = function ( params, async ) { var m = document.getElementById('no_change_label').getAttribute('value'); document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' '); document.getElementById('no_change_label').setAttribute('hidden','false'); + if (typeof params.info_blurb == 'function') { + params.info_blurb( mis_scan_msg ); + } } break; case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;