[open-ils-commits] r14587 - in trunk/Open-ILS/xul/staff_client: chrome/content/main server/circ server/locale/en-US server/patron (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Oct 23 18:34:24 EDT 2009


Author: phasefx
Date: 2009-10-23 18:34:17 -0400 (Fri, 23 Oct 2009)
New Revision: 14587

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
   trunk/Open-ILS/xul/staff_client/server/circ/util.js
   trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
   trunk/Open-ILS/xul/staff_client/server/patron/holds.js
   trunk/Open-ILS/xul/staff_client/server/patron/holds_overlay.xul
Log:
Make use of streaming batch hold update method in staff client and tie it to a progress meter

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-10-23 20:57:28 UTC (rev 14586)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-10-23 22:34:17 UTC (rev 14587)
@@ -115,6 +115,7 @@
     'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' },
     'FM_AHR_UNCANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.uncancel' },
     'FM_AHR_UPDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update' },
+    'FM_AHR_UPDATE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update.batch' },
     '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' },
     'FM_AHRCC_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.ahrcc.atomic', 'secure' : false },

Modified: trunk/Open-ILS/xul/staff_client/server/circ/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/circ/util.js	2009-10-23 20:57:28 UTC (rev 14586)
+++ trunk/Open-ILS/xul/staff_client/server/circ/util.js	2009-10-23 22:34:17 UTC (rev 14587)
@@ -7,7 +7,7 @@
 circ.util.EXPORT_OK    = [
     'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
     'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
-    'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin'
+    'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin', 'batch_hold_update'
 ];
 circ.util.EXPORT_TAGS    = { ':all' : circ.util.EXPORT_OK };
 
@@ -2978,4 +2978,46 @@
     }
 };
 
+circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
+    try {
+        JSAN.use('util.sound'); var sound = new util.sound();
+        var change_list = []; var idx = -1; var bad_holds = [];
+        dojo.forEach(
+            hold_ids,
+            function(el) {
+                change_list.push( function(id,fc){ var clone = JSON2js(js2JSON(fc)); clone.id = id; return clone; }(el,field_changes) ); // Is there a better way to do this?
+            }
+        );
+        if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
+        fieldmapper.standardRequest(
+            [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
+            {   async: true,
+                params: [ses(), null, change_list],
+                onresponse: function(r) {
+                    idx++; 
+                    if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
+                    var result = r.recv().content();
+                    if (result != hold_ids[ idx ]) {
+                        bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
+                    }
+                },
+                oncomplete: function() {
+                    if (bad_holds.length > 0) {
+                        sound.circ_bad();
+                        alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
+                    } else {
+                        sound.circ_good();
+                    }
+                    if (typeof params.oncomplete == 'function') {
+                        params.oncomplete( bad_holds );
+                    }
+                    if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
+                }
+            }
+        );
+    } catch(E) {
+        alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
+    }
+};
+
 dump('exiting circ/util.js\n');

Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties	2009-10-23 20:57:28 UTC (rev 14586)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties	2009-10-23 22:34:17 UTC (rev 14587)
@@ -378,6 +378,7 @@
 staff.circ.holds.modifying_holds=Modifying Holds
 staff.circ.holds.modifying_holds.yes=Yes
 staff.circ.holds.modifying_holds.no=No
+staff.circ.hold_update.hold_ids.failed=Number of holds not updated: %1$s 
 staff.circ.holds.already_activated=Hold %1$s was already activated.
 staff.circ.holds.already_activated.plural=Holds %1$s were already activated.
 staff.circ.holds.already_suspended=Hold %1$s was already suspended.

Modified: trunk/Open-ILS/xul/staff_client/server/patron/holds.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/holds.js	2009-10-23 20:57:28 UTC (rev 14586)
+++ trunk/Open-ILS/xul/staff_client/server/patron/holds.js	2009-10-23 22:34:17 UTC (rev 14587)
@@ -40,6 +40,8 @@
         obj.shelf = params['shelf'];
         obj.tree_id = params['tree_id'];
 
+        var progressmeter = document.getElementById('progress');
+
         JSAN.use('circ.util');
         var columns = circ.util.hold_columns(
             {
@@ -316,12 +318,12 @@
                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
                                 var selection = fancy_prompt_data.selection;
 
-                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(obj.retrieve_ids.length > 1) {
-                                    msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list, obj.data.hash.aout[selection].opac_label()])
+                                    msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
                                 } else {
-                                    msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list, obj.data.hash.aout[selection].opac_label()])
+                                    msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
                                 }
 
                                 var r = obj.error.yns_alert(msg,
@@ -332,14 +334,7 @@
                                         $("commonStrings").getString('common.check_to_confirm')
                                 );
                                 if (r == 0) {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.selection_depth( obj.data.hash.aout[selection].depth() ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
@@ -402,12 +397,12 @@
                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
                                 var pickup_lib = fancy_prompt_data.lib;
 
-                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(obj.retrieve_ids.length > 1) {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list.join(', '), obj.data.hash.aou[pickup_lib].shortname()]);
                                 } else {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.singular',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.singular',[hold_list.join(', '), obj.data.hash.aou[pickup_lib].shortname()]);
                                 }
                                 var r = obj.error.yns_alert(msg,
                                         $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
@@ -417,14 +412,7 @@
                                         $("commonStrings").getString('common.check_to_confirm')
                                 );
                                 if (r == 0) {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.pickup_lib(  pickup_lib ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
@@ -460,12 +448,12 @@
                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
                                 var phone = fancy_prompt_data.phone;
 
-                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(obj.retrieve_ids.length > 1) {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list, phone]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
                                 } else {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list, phone]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
                                 }
                                 var r = obj.error.yns_alert(msg,
                                         $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
@@ -475,14 +463,7 @@
                                         $("commonStrings").getString('common.check_to_confirm')
                                 );
                                 if (r == 0) {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.phone_notify(  phone ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
@@ -518,19 +499,19 @@
                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
                                 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
 
-                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(get_bool(email)) {
                                     if(obj.retrieve_ids.length > 1) {
-                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list]);
+                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
                                     } else {
-                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list]);
+                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
                                     }
                                 } else {
                                     if(obj.retrieve_ids.length > 1) {
-                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list]);
+                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
                                     } else {
-                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list]);
+                                        msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
                                     }
                                 }
 
@@ -542,14 +523,7 @@
                                         $("commonStrings").getString('common.check_to_confirm')
                                 );
                                 if (r == 0) {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.email_notify(  email ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
@@ -560,11 +534,11 @@
                         ['command'],
                         function() {
                             try {
-                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var r = obj.error.yns_alert(
                                     obj.retrieve_ids.length > 1 ?
-                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list]) :
-                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list]),
+                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
+                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
@@ -572,26 +546,23 @@
                                     document.getElementById('commonStrings').getString('common.confirm')
                                 );
                                 if (r == 0) {
-                                    var already_suspended = [];
+                                    var already_suspended = []; var filtered_hold_list = [];
                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                         var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
                                         if ( get_bool( hold.frozen() ) ) {
                                             already_suspended.push( hold.id() );
                                             continue;
                                         }
-                                        hold.frozen('t');
-                                        hold.thaw_date(null);
-                                        hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
+                                        filtered_hold_list.push( hold.id() );
                                     }
-                                    if (already_suspended.length == 1) {
-                                        alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
-                                    } else if (already_suspended.length > 1) {
-                                        alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { 
+                                        if (already_suspended.length == 1) {
+                                            alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
+                                        } else if (already_suspended.length > 1) {
+                                            alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
+                                        }
+                                        obj.clear_and_retrieve(true); 
+                                    } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
@@ -602,11 +573,11 @@
                         ['command'],
                         function() {
                             try {
-                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var r = obj.error.yns_alert(
                                     obj.retrieve_ids.length > 1 ?
-                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list]) :
-                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list]),
+                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
+                                    document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
@@ -614,26 +585,23 @@
                                     document.getElementById('commonStrings').getString('common.confirm')
                                 );
                                 if (r == 0) {
-                                    var already_activated = [];
+                                    var already_activated = []; var filtered_hold_list = [];
                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                         var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
                                         if ( ! get_bool( hold.frozen() ) ) {
                                             already_activated.push( hold.id() );
                                             continue;
                                         }
-                                        hold.frozen('f');
-                                        hold.thaw_date(null);
-                                        hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
+                                        filtered_hold_list.push( hold.id() );
                                     }
-                                    if (already_activated.length == 1) {
-                                        alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
-                                    } else if (already_activated.length > 1) {
-                                        alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { 
+                                        if (already_activated.length == 1) {
+                                            alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
+                                        } else if (already_activated.length > 1) {
+                                            alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
+                                        }
+                                        obj.clear_and_retrieve(true); 
+                                    } });
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
@@ -658,9 +626,9 @@
                                     }
                                 }
 
-                                var hold_ids = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
-                                var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
-                                var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
+                                var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
+                                var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
                                 var value = 'YYYY-MM-DD';
                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
@@ -674,15 +642,11 @@
                                     }
                                 }
                                 if (thaw_date || thaw_date == '') {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.frozen('t');
-                                        hold.thaw_date(  thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(
+                                        hold_list, 
+                                        { 'frozen' : 't', 'thaw_date' : thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') }, 
+                                        { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
+                                    );
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
@@ -707,9 +671,9 @@
                                     }
                                 }
 
-                                var hold_ids = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
-                                var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
-                                var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
+                                var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
+                                var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
                                 var value = 'YYYY-MM-DD';
                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
@@ -723,14 +687,11 @@
                                     }
                                 }
                                 if (expire_time || expire_time == '') {
-                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
-                                        hold.expire_time(  expire_time == '' ? null : util.date.formatted_date(expire_time + ' 00:00:00','%{iso8601}') ); hold.ischanged('1');
-                                        hold = obj.flatten_copy(hold);
-                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
-                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
-                                    }
-                                    obj.clear_and_retrieve(true);
+                                    circ.util.batch_hold_update(
+                                        hold_list, 
+                                        { 'expire_time' : expire_time == '' ? null : util.date.formatted_date(expire_time + ' 00:00:00','%{iso8601}') }, 
+                                        { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
+                                    );
                                 }
                             } catch(E) {
                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
@@ -746,12 +707,12 @@
                             try {
                                 JSAN.use('util.functional');
 
-                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(obj.retrieve_ids.length > 1) {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
                                 } else {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
                                 }
                                 var r = obj.error.yns_alert(msg,
                                         $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
@@ -780,12 +741,12 @@
                             try {
                                 JSAN.use('util.functional');
 
-                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+                                var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
                                 var msg = '';
                                 if(obj.retrieve_ids.length > 1 ) {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
                                 } else {
-                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list]);
+                                    msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
                                 }
 
                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

Modified: trunk/Open-ILS/xul/staff_client/server/patron/holds_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/holds_overlay.xul	2009-10-23 20:57:28 UTC (rev 14586)
+++ trunk/Open-ILS/xul/staff_client/server/patron/holds_overlay.xul	2009-10-23 22:34:17 UTC (rev 14587)
@@ -101,6 +101,7 @@
         <vbox id="lib_menu_placeholder" hidden="true"/>
         <button id="fetch_more" label="&staff.patron.holds_overlay.fetch_more.label;" accesskey="&staff.patron.holds_overlay.fetch_more.accesskey;" hidden="true"/>
     <spacer flex="1"/>
+        <progressmeter id="progress" type="determined" hidden="true" />
         <button id="alt_view_btn" command="cmd_alt_view" />
         <menubar>
             <menu label="&staff.patron.holds_overlay.actions_for_holds.label;" accesskey="&staff.patron.holds_overlay.actions_for_holds.accesskey;">



More information about the open-ils-commits mailing list