From: erickson Date: Wed, 18 Nov 2009 21:58:35 +0000 (+0000) Subject: Patch from Lebbeous Fogle-Weekley to remove some duplicate network calls in the copy... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4bafdd4c6c930f27f721c737ccd28aa48db1e233;p=contrib%2FConifer.git Patch from Lebbeous Fogle-Weekley to remove some duplicate network calls in the copy status and details UI git-svn-id: svn://svn.open-ils.org/ILS/trunk@14959 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js index 2b4f29a29f..403797da80 100644 --- a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js +++ b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js @@ -14,7 +14,11 @@ function my_init() { JSAN.use('util.network'); network = new util.network(); JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve(); - setTimeout( function() { load_item(); }, 1000 ); // timeout so xulG gets a chance to get pushed in + // timeout so xulG gets a chance to get pushed in + setTimeout( + function () { xulG.from_item_details_new = false; load_item(); }, + 1000 + ); } catch(E) { try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); } @@ -57,8 +61,15 @@ function load_item() { try { if (! xulG.barcode) return; - var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]); - // Should get back .mvr, .copy, .volume, .transit, .circ, .hold + if (xulG.fetched_copy_details && xulG.fetched_copy_details[xulG.barcode]) { + var details = xulG.fetched_copy_details[xulG.barcode]; + // We don't want to use these details more than once (i.e., we + // don't want cached data after things have potentially changed). + delete xulG.fetched_copy_details[xulG.barcode]; + } else { + var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]); + // Should get back .mvr, .copy, .volume, .transit, .circ, .hold + } if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } ); /* 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 c89dc731c5..0f22cbf20c 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -1165,13 +1165,12 @@ circ.copy_status.prototype = { } obj.controller.view.copy_status_barcode_entry_textbox.value = ''; obj.controller.view.copy_status_barcode_entry_textbox.focus(); - + return result; // In some cases we're going to want to save this } catch(E) { obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E); obj.controller.view.copy_status_barcode_entry_textbox.select(); obj.controller.view.copy_status_barcode_entry_textbox.focus(); } - }, 'spawn_copy_editor' : function() { 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 4303211a26..1c7f65de3f 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.xul @@ -61,33 +61,7 @@ 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; - } - - // 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 < window.xulG.barcodes.length; i++) { - funcs.push( - function(b){ - return function() { - g.copy_status.copy_status(b); - } - }(window.xulG.barcodes[i]) - ); - } - setTimeout(function() { exec.chain(funcs); }, 1000); + g.barcodes = window.xulG.barcodes; } else { g.barcodes = xul_param( 'barcodes',{ @@ -97,26 +71,28 @@ '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); - } + window.xulG.fetched_copy_details = {}; + + 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); + } + + 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() { + window.xulG.fetched_copy_details[b] = + g.copy_status.copy_status(b); + } + }(g.barcodes[i]) + ); } + exec.chain(funcs); } 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); }