LP#1710010: Fix item status file upload
authorMike Rylander <mrylander@gmail.com>
Thu, 10 Aug 2017 20:41:03 +0000 (16:41 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 11 Aug 2017 21:20:23 +0000 (17:20 -0400)
The item service currently living inside the item status app does not know how
to fetch multiple barcodes at once.  So, we'll loop over them and refresh the
grid when they're all retrieved.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index 5628a48..5c6ab73 100644 (file)
@@ -1107,12 +1107,19 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
                 barcodes.push(line);
             });
 
-            itemSvc.fetch(barcodes).then(
-                function() {
-                    copyGrid.refresh();
-                    copyGrid.selectItems([itemSvc.copies[0].index]);
-                }
-            );
+            if (barcodes.length > 0) {
+                var promises = [];
+                angular.forEach(barcodes, function (b) {
+                    promises.push(itemSvc.fetch(b));
+                });
+
+                $q.all(promises).then(
+                    function() {
+                        copyGrid.refresh();
+                        copyGrid.selectItems([itemSvc.copies[0].index]);
+                    }
+                );
+            }
         }
     });