LP#1775276 Web Client: Check In - "Route To" Field Sometimes Incorrect user/dbriem/lp1775276_route_to_sometimes_incorrect
authorDan Briem <dbriem@wlsmail.org>
Fri, 29 Nov 2019 19:51:06 +0000 (14:51 -0500)
committerDan Briem <dbriem@wlsmail.org>
Fri, 29 Nov 2019 19:51:06 +0000 (14:51 -0500)
When open-ils.circ.checkin closes a transit and creates a new one, the payload
only returns the closed transit. The route dialogs perform a pcrud search to
get the most recent transit, but the grid's Route To field still depends on the
transit returned by the API, so received transits display the old destination
in the Route To field instead of the shelving location or new destination.

This branch returns the most recent route info collected by the route dialog
and, if the most recent transit destination doesn't match the old one, the new
one is assigned to the route_to prop on the final_resp. It also checks that the
transit is open before displaying the destination in the Route To field so the
shelving location displays if the most recent transit is closed.

To test:
1. Sign in as Library A and check in an item owned by Library B
2. Place a copy hold on the item with a pickup location of Library C
3. Sign in as Library B and check in the item - note the dialog is correct but
   the grid's Route To field displays Library B instead of Library C
4. Apply patch
5. Repeat steps 1-3, note the Route To field displays Library C

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index 4a3ce9c..c3c5657 100644 (file)
@@ -355,7 +355,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
             data.mbts = payload.parent_circ.billable_transaction().summary();
 
         if (!data.route_to) {
-            if (data.transit) {
+            if (data.transit && !data.transit.dest_recv_time() && !data.transit.cancel_time()) {
                 data.route_to = data.transit.dest().shortname();
             } else if (data.acp) {
                 data.route_to = data.acp.location().name();
@@ -1708,7 +1708,11 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                 return service.route_dialog(
                     './circ/share/t_transit_dialog', 
                     evt[0], params, options
-                ).then(function() { return final_resp });
+                ).then(function(data) {
+                    if (transit && data.transit && transit.dest().id() != data.transit.dest().id())
+                        final_resp.evt[0].route_to = data.transit.dest().shortname();
+                    return final_resp;
+                });
 
             case 'ASSET_COPY_NOT_FOUND':
                 egCore.audio.play('error.checkin.not_found');
@@ -1791,7 +1795,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                 // do not show the dialog or print if the
                 // disabled automatic print attempt type list includes
                 // the specified template
-                return;
+                return data;
             }
 
             // All actions flow from the print data
@@ -1840,7 +1844,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                     context : 'default', 
                     template : template, 
                     scope : print_context
-                });
+                }).then(function() { return data });
             }
 
             // when auto-print is on, skip the dialog and go straight
@@ -1870,7 +1874,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                     }
                 }]
 
-            }).result;
+            }).result.then(function() { return data });
         });
     }