make batch renewal use synchronous calls again to better handle exceptions. The...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Mar 2010 20:03:51 +0000 (20:03 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Mar 2010 20:03:51 +0000 (20:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15875 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/items.js

index 262a511..8444e42 100644 (file)
@@ -279,13 +279,15 @@ patron.items.prototype = {
             }
             var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.renew_items_in_list'));
             if (!r) return;
+            obj.list.select_all();
             function flesh_callback() {
                 try {
-                    obj.list.select_all();
-                    params.skip_prompt = true;
-                    if (!params.which_list) params.which_list = 1;
-                    obj.items_renew(params);    
-                    setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0);
+                    setTimeout(function(){
+                            list.on_all_fleshed = null;
+                            params.skip_prompt = true;
+                            if (!params.which_list) params.which_list = 1;
+                            obj.items_renew(params);    
+                        },0);
                 } catch(E) {
                     obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['2']),E);
                 }
@@ -365,33 +367,29 @@ patron.items.prototype = {
                 }
                 var p = { 'barcode' : bc, 'patron' : obj.patron_id };
                 if (params.due_date) p.due_date = params.due_date;
-                var renew = circ.util.renew_via_barcode(
-                    p, 
-                    function(r) {
-                        try {
-                            if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
-                                l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewed',[bc]));
-                                obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ;
-                                obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy;
-                                obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record;
-                                // A renewed circ is a new circ, and has a new circ_id.
-                                obj.list_circ_map[ r[0].payload.circ.id() ] = obj.list_circ_map[ circ_id ];
-                            } else {
-                                var msg = $("patronStrings").getFormattedString('staff.patron.items.items_renew.not_renewed',[bc, r[0].textcode + r[0].desc]);
-                                l.setAttribute('value', msg);
-                                alert(msg);
-                            }
-                            count--;
-                            if (count == 0) {
-                                //if (window.confirm('Action completed. Refresh list?')) obj.retrieve();
-                                JSAN.use('util.widgets'); util.widgets.remove_children(x);
-                            }
-                            obj.refresh(circ_id);
-                        } catch(E) {
-                              obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E);
-                        }
-                    } 
-                );
+                var r = circ.util.renew_via_barcode( p );
+                try {
+                    if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
+                        l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewed',[bc]));
+                        obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ;
+                        obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy;
+                        obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record;
+                        // A renewed circ is a new circ, and has a new circ_id.
+                        obj.list_circ_map[ r[0].payload.circ.id() ] = obj.list_circ_map[ circ_id ];
+                    } else {
+                        var msg = $("patronStrings").getFormattedString('staff.patron.items.items_renew.not_renewed',[bc, r[0].textcode + r[0].desc]);
+                        l.setAttribute('value', msg);
+                        alert(msg);
+                    }
+                    count--;
+                    if (count == 0) {
+                        //if (window.confirm('Action completed. Refresh list?')) obj.retrieve();
+                        JSAN.use('util.widgets'); util.widgets.remove_children(x);
+                    }
+                    obj.refresh(circ_id);
+                } catch(E) {
+                      obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E);
+                }
             }
 
             for (var i = 0; i < retrieve_ids.length; i++) {