Saner behavior for Actions for Selected Holds -> Transfer to Marked Title user/phasefx/selective_title_hold_transfer
authorJason Etheridge <jason@esilibrary.com>
Mon, 27 Jun 2011 19:19:21 +0000 (15:19 -0400)
committerJason Etheridge <jason@esilibrary.com>
Mon, 27 Jun 2011 19:30:11 +0000 (15:30 -0400)
Transfer the actual selected title holds, rather than all title holds for the bibs referenced by those selected.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
Open-ILS/xul/staff_client/server/patron/holds.js

index 6743d95..d02c172 100644 (file)
@@ -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' },
index 98e7e49..ea543b7 100644 (file)
@@ -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();
index f75c4e9..f035034 100644 (file)
@@ -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.
index 085c54a..c486009 100644 (file)
@@ -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);