checkin; fetch transit for route-to as needed
authorBill Erickson <berick@esilibrary.com>
Wed, 9 Jul 2014 15:25:03 +0000 (11:25 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 9 Jul 2014 15:25:03 +0000 (11:25 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index 9dc405b..f2d6884 100644 (file)
@@ -475,13 +475,31 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) {
         if (!evt || !(payload = evt.payload)) return $q.when();
 
         promises.push(service.flesh_copy_location(payload.copy));
-        promises.push(service.flesh_copy_status(payload.copy));
+        promises.push(
+            service.flesh_copy_status(payload.copy)
+
+            .then(function() {
+                // copy is in transit, but no transit was delivered
+                // in the payload.  Do this here instead of below to
+                // ensure consistent copy status fleshiness
+                if (!payload.transit && payload.copy.status().id() == 6) { // in-transit
+                    return service.find_copy_transit(evt, params, options)
+                    .then(function(trans) {
+                        if (trans) {
+                            trans.source(egCore.org.get(trans.source()));
+                            trans.dest(egCore.org.get(trans.dest()));
+                            payload.transit = trans;
+                        }
+                    })
+                }
+            })
+        );
 
         // local flesh transit
         if (transit = payload.transit) {
             transit.source(egCore.org.get(transit.source()));
             transit.dest(egCore.org.get(transit.dest()));
-        }
+        } 
 
         // TODO: renewal responses should include the patron
         if (!payload.patron && payload.circ) {