LP#1932051: serialize adding items to bucket from Item Status
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 23 Aug 2021 18:24:05 +0000 (11:24 -0700)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 7 Sep 2021 15:19:35 +0000 (11:19 -0400)
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>

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

index fa62c85..56d82bf 100644 (file)
@@ -249,24 +249,23 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
                 ).then(function(buckets) { $scope.allBuckets = buckets; });
 
                 $scope.add_to_bucket = function() {
-                    var promises = [];
+                    var promise = $q.when();
                     angular.forEach(list, function (entry) {
                         var item = bucket_type == 'copy' ? new egCore.idl.ccbi() : new egCore.idl.cbrebi();
                         item.bucket($scope.bucket_id);
                         if (bucket_type == 'copy') item.target_copy(entry);
                         if (bucket_type == 'biblio') item.target_biblio_record_entry(entry);
-                        promises.push(
-                            egCore.net.request(
+                        promise = promise.then(function() {
+                            return egCore.net.request(
                                 'open-ils.actor',
                                 'open-ils.actor.container.item.create',
                                 egCore.auth.token(), bucket_type, item
-                            )
-                        );
-
-                        return $q.all(promises).then(function() {
-                            $uibModalInstance.close();
+                            );
                         });
                     });
+                    promise.then(function() {
+                        $uibModalInstance.close();
+                    });
                 }
 
                 $scope.add_to_new_bucket = function() {