updating item out count in patron display
authorJason Etheridge <jason@esilibrary.com>
Fri, 9 Mar 2012 09:45:14 +0000 (04:45 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 23 Mar 2012 20:30:29 +0000 (16:30 -0400)
For checkouts (and checkouts converted into renewals), this updates the item out
count in the patron summary sidebar, and under the Items Out navigation button.

It also updates the Items Out sub-interface if that interface has been opened.

However, we are adding an extra network call to update the summary sidebar.  We
may want to have the checkout method return that data (the checkout count
summary) instead.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/patron/display.js
Open-ILS/xul/staff_client/server/patron/items.js

index ee4d317..92bece2 100644 (file)
@@ -436,11 +436,17 @@ circ.checkout.prototype = {
                             //I could override map_row_to_column here
                             }
                         );
+                        var is_renewal = (
+                            get_bool(checkout.payload.circ.opac_renewal())
+                            ||get_bool(checkout.payload.circ.phone_renewal())
+                            ||get_bool(checkout.payload.circ.desk_renewal())
+                        );
                         try {
                             obj.error.work_log(
                                 document.getElementById('circStrings').getFormattedString(
-                                    (get_bool(checkout.payload.circ.opac_renewal())||get_bool(checkout.payload.circ.phone_renewal())||get_bool(checkout.payload.circ.desk_renewal())) ?
-                                        'staff.circ.work_log_renew.message' : 'staff.circ.work_log_checkout.message',
+                                        is_renewal
+                                        ? 'staff.circ.work_log_renew.message'
+                                        : 'staff.circ.work_log_checkout.message',
                                     [
                                         ses('staff_usrname'),
                                         xulG.patron.family_name(),
@@ -464,7 +470,7 @@ circ.checkout.prototype = {
                         }
                         */
                         if (typeof window.xulG == 'object' && typeof window.xulG.on_list_change == 'function') {
-                            window.xulG.on_list_change(checkout.payload);
+                            window.xulG.on_list_change(checkout.payload,is_renewal);
                         } else {
                             obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
                         }
index f18ecf5..054e364 100644 (file)
@@ -844,30 +844,43 @@ patron.display.prototype = {
                     'patron_id' : obj.patron.id(),
                     'patron' : obj.patron,
                     'check_stop_checkouts' : function() { return obj.check_stop_checkouts(); },
-                    'on_list_change' : function(checkout) {
+                    'on_list_change_old' : function(checkout) {
                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                         var x = obj.summary_window.g.summary.controller.view.patron_checkouts;
                         var n = Number(x.getAttribute('value'));
                         x.setAttribute('value',n+1);
                     },
-                    'on_list_change_old' : function(checkout) {
+                    'on_list_change' : function(checkout,is_renewal) {
                     
-                        /* this stops noncats from getting pushed into Items Out */
-                        if (!checkout.circ.id()) return; 
-
                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                        // Downside here: an extra network call, open-ils.actor.user.checked_out.count.authoritative
                         obj.summary_window.g.summary.controller.render('patron_checkouts');
                         obj.summary_window.g.summary.controller.render('patron_standing_penalties');
+
+                        /* this stops noncats from getting pushed into Items Out */
+                        if (!checkout.circ.id()) return;
+
                         if (obj.items_window) {
-                            obj.items_window.g.items.list.append(
-                                {
-                                    'row' : {
-                                        'my' : {
-                                            'circ_id' : checkout.circ.id()
-                                        }
+                            if (is_renewal) {
+                                var original_circ_id = obj.items_window.g.items.list_circ_map_by_copy[ checkout.circ.target_copy() ];
+                                obj.items_window.g.items.list_circ_map[ original_circ_id ].row.my.circ = checkout.circ;
+                                obj.items_window.g.items.list_circ_map[ checkout.circ.id() ] =
+                                    obj.items_window.g.items.list_circ_map[ original_circ_id ];
+                                obj.items_window.g.items.refresh( checkout.circ.id() );
+                            } else {
+                                var nparams = obj.items_window.g.items.list.append(
+                                    {
+                                        'row' : {
+                                            'my' : {
+                                                'circ_id' : checkout.circ.id()
+                                            }
+                                        },
+                                        'to_bottom' : true
                                     }
-                                }
-                            )
+                                )
+                                obj.items_window.g.items.list_circ_map[ checkout.circ.id() ] = nparams;
+                                obj.items_window.g.items.list_circ_map_by_copy[ checkout.circ.target_copy() ] = checkout.circ.id();
+                            }
                         }
                     },
                     'get_barcode' : xulG.get_barcode,
index ee7215e..a38f728 100644 (file)
@@ -14,6 +14,7 @@ patron.items = function (params) {
 patron.items.prototype = {
 
     'list_circ_map' : {},
+    'list_circ_map_by_copy' : {},
 
     'init' : function( params ) {
 
@@ -392,6 +393,7 @@ patron.items.prototype = {
                         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 ];
+                        obj.list_circ_map_by_copy[ r[0].payload.copy.id() ] = r[0].payload.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);
@@ -464,6 +466,7 @@ patron.items.prototype = {
                         var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],my_xulG.timestamp]);
                         if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
                         obj.list_circ_map[ circs[i] ].row.my.circ = robj;
+                        obj.list_circ_map_by_copy[ robj.target_copy() ] = circs[i];
                         obj.refresh(circs[i]);
                     }
                 }
@@ -746,6 +749,8 @@ patron.items.prototype = {
                                 }
                                 
                                 params.treeitem_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) );
+
+                                obj.list_circ_map_by_copy[ copy_id ] = row.my.circ.id();
             
                                 if (typeof params.on_retrieve == 'function') {
                                     params.on_retrieve(row);