LP#1402797 Fetch old circ when the user is not the same (API misuse)
authorMike Rylander <mrylander@gmail.com>
Wed, 3 Dec 2014 15:53:35 +0000 (10:53 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Feb 2015 16:58:27 +0000 (11:58 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index 9a0b8a7..29dec1e 100644 (file)
@@ -803,6 +803,27 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) {
 
     service.circ_exists_dialog = function(evt, params, options) {
 
+        if (!evt.payload.old_circ) {
+            return egCore.net.request(
+                'open-ils.search',
+                'open-ils.search.asset.copy.fleshed2.find_by_barcode',
+                params.copy_barcode
+            ).then(function(resp){
+                console.log(resp);
+                if (egCore.evt.parse(resp)) {
+                    console.error(egCore.evt.parse(resp));
+                } else {
+                   evt.payload.old_circ = resp.circulations()[0];
+                   return service.circ_exists_dialog_impl( evt, params, options );
+                }
+            });
+        } else {
+            return service.circ_exists_dialog_impl( evt, params, options );
+        }
+    },
+
+    service.circ_exists_dialog_impl = function (evt, params, options) {
+
         var openCirc = evt.payload.old_circ;
         var sameUser = openCirc.usr() == params.patron_id;