From 4b5ddb4bea8071f4d51e38087b97684e7d3151cc Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 27 Jun 2011 15:19:21 -0400 Subject: [PATCH] Saner behavior for Actions for Selected Holds -> Transfer to Marked Title Transfer the actual selected title holds, rather than all title holds for the bibs referenced by those selected. Signed-off-by: Jason Etheridge --- .../staff_client/chrome/content/main/constants.js | 1 + Open-ILS/xul/staff_client/server/cat/util.js | 33 +++++++++++++++++++++- .../server/locale/en-US/cat.properties | 1 + Open-ILS/xul/staff_client/server/patron/holds.js | 15 +++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) 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 6743d9588f..d02c17224f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -145,6 +145,7 @@ var api = { 'FM_AHR_RESET' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.reset' }, 'FM_AHR_STATUS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.status.retrieve' }, 'TRANSFER_TITLE_HOLDS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.change_title' }, + 'TRANSFER_SPECIFIC_TITLE_HOLDS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.change_title.specific_holds' }, 'FM_AHRCC_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.ahrcc.atomic', 'secure' : false }, 'FM_AIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.in_house_use.create' }, 'FM_ANCC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cataloged_circulation.retrieve' }, diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 98e7e4956b..ea543b7722 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -9,7 +9,7 @@ cat.util.EXPORT_OK = [ 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', 'transfer_title_holds', 'mark_item_missing', 'mark_item_damaged', 'replace_barcode', 'fast_item_add', 'make_bookable', 'edit_new_brsrc', 'edit_new_bresv', 'batch_edit_volumes', 'render_fine_level', - 'render_loan_duration', 'mark_item_as_missing_pieces' + 'render_loan_duration', 'mark_item_as_missing_pieces', 'transfer_specific_title_holds' ]; cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK }; @@ -115,6 +115,37 @@ cat.util.transfer_title_holds = function(old_targets) { } } +cat.util.transfer_specific_title_holds = function(hold_ids,unique_targets) { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); + JSAN.use('util.network'); var network = new util.network(); + try { + data.stash_retrieve(); + var target = data.marked_record_for_hold_transfer; + if (!target) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label'); + alert(m); + return; + } + if (unique_targets.length > 1) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.many_bibs.warning'); + if (! window.confirm(m)) { + return; + } + } + var robj = network.simple_request('TRANSFER_SPECIFIC_TITLE_HOLDS',[ ses(), target, hold_ids ]); + if (robj == 1) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label'); + alert(m); + } else { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label'); + alert(m); + } + } catch(E) { + alert('Error in cat.util.transfer_title.holds(): ' + E); + } +} + + cat.util.transfer_copies = function(params) { JSAN.use('util.error'); var error = new util.error(); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index f75c4e9ca4..f035034882 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -281,6 +281,7 @@ staff.cat.opac.set_tab_name=Record: %1$s staff.cat.opac.title_for_hold_transfer.destination_needed.label=Need to mark a record as a Title Hold Transfer Destination first. staff.cat.opac.title_for_hold_transfer.success.label=Holds transferred. staff.cat.opac.title_for_hold_transfer.failure.label=Holds not transferred. +staff.cat.opac.title_for_hold_transfer.many_bibs.warning=WARNING: Move selected holds from multiple bibs to single targeted bib? staff.cat.record_buckets.tab_name=Record Buckets staff.cat.record_buckets.save_file_as=Save File As staff.cat.record_buckets.export_records.alert=File not downloaded. diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 085c54ab6b..c48600917d 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -1198,16 +1198,23 @@ patron.holds.prototype = { ['command'], function() { try { - var targets = []; + var hids = []; + var unique_targets = []; + var seen_target = {}; for (var i = 0; i < obj.retrieve_ids.length; i++) { - var htarget = obj.retrieve_ids[i].target; + var hid = obj.retrieve_ids[i].id; + var htarget = obj.retrieve_ids[i].id; var htype = obj.retrieve_ids[i].type; switch(htype) { case 'M' : continue; // not supported break; case 'T' : - targets.push( htarget ); + hids.push( hid ); + if (! seen_target[htarget]) { + unique_targets.push( htarget ); + seen_target[htarget] = 1; + } break; case 'V' : continue; // not supported @@ -1221,7 +1228,7 @@ patron.holds.prototype = { } } JSAN.use('cat.util'); - cat.util.transfer_title_holds(targets); + cat.util.transfer_specific_title_holds(hids,unique_targets); obj.clear_and_retrieve(); } catch(E) { obj.error.standard_unexpected_error_alert('',E); -- 2.11.0