From 5e97a10f3cf547721963718097905cc7505a1721 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 18 Nov 2009 13:33:31 +0000 Subject: [PATCH] Patch from Lebbeous Fogle-Weekley to change the behavior of the "Show Item Details" context menu entry for patron items out, checkin, transit list, copy status, renewal, hold shelf. Action now opens a new Item Status tab with the alternate (details) view focused by default. Works with single or multiple copies. TODO: no need to fetch copy details twice for the same copy git-svn-id: svn://svn.open-ils.org/ILS/trunk@14951 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/admin/transit_list.js | 11 +++- Open-ILS/xul/staff_client/server/circ/checkin.js | 9 ++- .../xul/staff_client/server/circ/copy_status.js | 19 +++++-- .../xul/staff_client/server/circ/copy_status.xul | 65 +++++++++++++++++----- Open-ILS/xul/staff_client/server/circ/renew.js | 9 ++- Open-ILS/xul/staff_client/server/circ/util.js | 13 +++++ Open-ILS/xul/staff_client/server/patron/holds.js | 9 ++- Open-ILS/xul/staff_client/server/patron/items.js | 7 ++- 8 files changed, 111 insertions(+), 31 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/admin/transit_list.js b/Open-ILS/xul/staff_client/server/admin/transit_list.js index 104c4c951..b04b4b818 100644 --- a/Open-ILS/xul/staff_client/server/admin/transit_list.js +++ b/Open-ILS/xul/staff_client/server/admin/transit_list.js @@ -405,7 +405,16 @@ admin.transit_list.prototype = { 'sel_opac' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.show_in_opac(obj.selection_list); } ], 'sel_transit_abort' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.abort_transits(obj.selection_list); } ], 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.selection_list); } ], - 'sel_copy_details' : [ ['command'], function() { JSAN.use('circ.util'); for (var i = 0; i < obj.selection_list.length; i++) { circ.util.show_copy_details( obj.selection_list[i].copy_id ); } } ], + 'sel_copy_details' : [ ['command'], + function() { + JSAN.use('circ.util'); + circ.util.item_details_new( + util.functional.map_list( + obj.selection_list, + function(o) { return o.barcode; } + ) + ); + } ], 'sel_bucket' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.add_copies_to_bucket(obj.selection_list); } ], 'cmd_print_list' : [ ['command'], function() { obj.print_list(0); } ], 'cmd_kick_off' : [ ['command'], function(ev) { ev.target.disabled = true; obj.kick_off(); } ], diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index d41fe987b..c895f0c8d 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -161,9 +161,12 @@ circ.checkin.prototype = { ['command'], function() { JSAN.use('circ.util'); - for (var i = 0; i < obj.selection_list.length; i++) { - circ.util.show_copy_details( obj.selection_list[i].copy_id ); - } + circ.util.item_details_new( + util.functional.map_list( + obj.selection_list, + function(o) { return o.barcode; } + ) + ); } ], 'sel_backdate' : [ diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index caed154c9..c89dc731c 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -276,9 +276,12 @@ circ.copy_status.prototype = { ['command'], function() { JSAN.use('circ.util'); - for (var i = 0; i < obj.selection_list.length; i++) { - circ.util.show_copy_details( obj.selection_list[i].copy_id ); - } + circ.util.item_details_new( + util.functional.map_list( + obj.selection_list, + function(o) { return o.barcode; } + ) + ); } ], 'sel_renew' : [ @@ -1148,8 +1151,14 @@ circ.copy_status.prototype = { var f = obj.browser.get_content(); xulG.barcode = result.copy.barcode(); // FIXME: We could pass the already-fetched data, but need to figure out how to manage that and honor Trim List, the whole point of which is to limit memory consumption if (f) { - f.xulG = xulG; - f.load_item(); + if (!xulG.from_item_details_new) { + /* We don't want to call load_item() in this case + * because we're going to call copy_status() later + * (which gets action menus populated, unlike + * load_item()). */ + f.xulG = xulG; + f.load_item(); + } } else { alert('hrmm'); } diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.xul b/Open-ILS/xul/staff_client/server/circ/copy_status.xul index de1ccc204..4303211a2 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.xul @@ -56,32 +56,67 @@ } } - JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); - - g.barcodes = xul_param( - 'barcodes',{ - 'concat' : true, - 'JSON2js_if_cgi' : true, - 'stash_name':'temp_barcodes_for_copy_status', - 'clear_xpcom' : true, + JSAN.use('OpenILS.data'); + g.data = new OpenILS.data(); + g.data.stash_retrieve(); + + if (window.xulG.barcodes && window.xulG.barcodes.length) { + if (window.xulG.from_item_details_new) { + // Switch item status display to "alternate view" + g.copy_status.controller.control_map.cmd_alt_view[1](0); + + // This property's truthiness should not persist any + // longer. Otherwise, user's won't get results if they + // enter a different barcode into the Alternate View. + window.xulG.from_item_details_new = false; } - ) || []; - - if (g.barcodes.length > 0) { + + // This timeout is needed to populate the + // "Actions for (Catalogers|Selected Items)" menus. + // Without this, the other fields still get populated + // with data about the item referred to by barcode, but + // for some reason those menus don't start working. JSAN.use('util.exec'); var exec = new util.exec(); var funcs = []; - for (var i = 0; i < g.barcodes.length; i++) { + for (var i = 0; i < window.xulG.barcodes.length; i++) { funcs.push( function(b){ return function() { g.copy_status.copy_status(b); } - }(g.barcodes[i]) + }(window.xulG.barcodes[i]) ); } - exec.chain( funcs ); + setTimeout(function() { exec.chain(funcs); }, 1000); + } else { + g.barcodes = xul_param( + 'barcodes',{ + 'concat' : true, + 'JSON2js_if_cgi' : true, + 'stash_name':'temp_barcodes_for_copy_status', + 'clear_xpcom' : true, + } + ) || []; + + if (g.barcodes.length > 0) { + JSAN.use('util.exec'); var exec = new util.exec(); + var funcs = []; + for (var i = 0; i < g.barcodes.length; i++) { + funcs.push( + function(b){ + return function() { + g.copy_status.copy_status(b); + } + }(g.barcodes[i]) + ); + } + if (window.xulG.from_item_details_new) { + g.copy_status.controller.control_map.cmd_alt_view[1](0); + window.xulG.from_item_details_new = false; + } + setTimeout(function() { exec.chain(funcs); }, 1000); + } } - } catch(E) { var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['circ.copy_status.xul', E]); try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } diff --git a/Open-ILS/xul/staff_client/server/circ/renew.js b/Open-ILS/xul/staff_client/server/circ/renew.js index 841098001..52b43d64e 100644 --- a/Open-ILS/xul/staff_client/server/circ/renew.js +++ b/Open-ILS/xul/staff_client/server/circ/renew.js @@ -158,9 +158,12 @@ circ.renew.prototype = { ['command'], function() { JSAN.use('circ.util'); - for (var i = 0; i < obj.selection_list.length; i++) { - circ.util.show_copy_details( obj.selection_list[i].copy_id ); - } + circ.util.item_details_new( + util.functional.map_list( + obj.selection_list, + function(o) { return o.barcode; } + ) + ); } ], 'sel_mark_items_damaged' : [ diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 2a108cd6c..b38b2b072 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -84,6 +84,19 @@ circ.util.show_copy_details = function(copy_id) { } }; +circ.util.item_details_new = function(barcodes) { + try { + var content_params = { + 'from_item_details_new': true, + 'barcodes': barcodes + }; + xulG.new_tab(urls.XUL_COPY_STATUS, {}, content_params); + } catch(E) { + JSAN.use('util.error'); + (new util.error()).standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E); + } +}; + circ.util.backdate_post_checkin = function(circ_ids) { var obj = {}; JSAN.use('util.error'); obj.error = new util.error(); diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 427c1974c..c6fa87592 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -275,9 +275,12 @@ patron.holds.prototype = { ['command'], function() { JSAN.use('circ.util'); - for (var i = 0; i < obj.retrieve_ids.length; i++) { - if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); - } + circ.util.item_details_new( + util.functional.map_list( + obj.retrieve_ids, + function(o) { return o.barcode; } + ) + ); } ], diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index dad4b09b9..6b5d63342 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -120,7 +120,12 @@ patron.items.prototype = { 'sel_copy_details' : [ ['command'], function() { JSAN.use('circ.util'); - for (var i = 0; i < obj.retrieve_ids.length; i++) { circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); } + circ.util.item_details_new( + util.functional.map_list( + obj.retrieve_ids, + function(o) { return o.barcode; } + ) + ); } ], 'sel_patron2' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids2); } ], -- 2.11.0