Fixed a logic error with renew. The patron Items Out interface keeps some state...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Aug 2007 03:47:48 +0000 (03:47 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Aug 2007 03:47:48 +0000 (03:47 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@7721 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 3aeb825..4ecfb09 100644 (file)
@@ -297,20 +297,26 @@ patron.items.prototype = {
                                }
                                var renew = circ.util.renew_via_barcode( barcode, obj.patron_id, 
                                        function(r) {
-                                               if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
-                                                       l.setAttribute('value', bc + ' renewed.');
-                                                       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;
-                                               } else {
-                                                       l.setAttribute('value', bc + ' not renewed.  ' + r[0].textcode + r[0].desc);
-                                               }
-                                               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);
+                        try {
+                            if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
+                                l.setAttribute('value', bc + ' renewed.');
+                                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 {
+                                l.setAttribute('value', bc + ' not renewed.  ' + r[0].textcode + r[0].desc);
+                            }
+                            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('Error in renew_via_barcode callback\nRenew probably did not happen for barcode ' + barcode,E);
+                        }
                                        } 
                                );
                        }
@@ -745,10 +751,10 @@ patron.items.prototype = {
                                        if (nparams) {
                                                obj.list_circ_map[circ_id] = nparams; // unlike item status interface, each circ should be in this list only once
                                        } else {
-                                               alert('foo');
+                                               throw('typeof nparams = ' + typeof nparams);
                                        }
                                } catch(E) {
-                                       alert(E);
+                                       obj.error.standard_unexpected_error_alert('patron/items.js: error in gen_list_append',E);
                                }
                        };
                }