LP#1362743 One modal at a time during batch checkin
authorMike Risher <mrisher@catalyte.io>
Wed, 6 May 2020 17:08:33 +0000 (17:08 +0000)
committerGalen Charlton <gmc@equinoxOLI.org>
Mon, 12 Jul 2021 14:48:38 +0000 (10:48 -0400)
Modify batch checkins so that only one modal pops up at a time.
When each one is dismissed the next one will appear.

Signed-off-by: Mike Risher <mrisher@catalyte.io>
Signed-off-by: Dawn Dale <ddale@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/web/js/ui/default/staff/circ/services/item.js

index 8522f15..3ffc96a 100644 (file)
@@ -614,11 +614,19 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
     }
 
     service.checkin = function (items) {
-        angular.forEach(items, function (cp) {
-            egCirc.checkin({copy_barcode:cp.barcode}).then(
-                function() { service.add_barcode_to_list(cp.barcode) }
-            );
-        });
+        // Recursive function that creates a promise for each item. Once the dialog 
+        // window for a given item is closed the next promise is started and a
+        // new dialog is opened. 
+        // This keeps multiple popups from hitting the screen at once.
+        (function checkinLoop(i) {
+            if (i < items.length) new Promise((resolve, reject) => {
+                egCirc.checkin({copy_barcode: items[i].barcode})
+                .then(function() {
+                    service.add_barcode_to_list(items[i].barcode);
+                    resolve();
+                })
+            }).then(checkinLoop.bind(null, i+1));
+        })(0);
     }
 
     service.renew = function (items) {