From: Chris Sharp <csharp@georgialibraries.org>
Date: Tue, 15 Jun 2021 15:59:48 +0000 (-0400)
Subject: LP#1932051: Batch calls for add items to bucket
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=057c6baec709fea9e306a7b7365ace248d7a65b8;p=evergreen%2Fmasslnc.git

LP#1932051: Batch calls for add items to bucket

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
---

diff --git a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js
index 4216128ca1..81372a1f68 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js
@@ -262,18 +262,19 @@ function($scope,  $location,  $q,  $timeout,  $uibModal,
     $scope.addToBucket = function(recs) {
         if (recs.length == 0) return;
         bucketSvc.bucketNeedsRefresh = true;
-
+        var promise = $q.when();
         angular.forEach(recs,
             function(rec) {
                 var item = new egCore.idl.ccbi();
                 item.bucket(bucketSvc.currentBucket.id());
                 item.target_copy(rec.id);
-                egCore.net.request(
-                    'open-ils.actor',
-                    'open-ils.actor.container.item.create', 
-                    egCore.auth.token(), 'copy', item
-                ).then(function(resp) {
-
+                promise = promise.then(function() {
+                    return egCore.net.request(
+                        'open-ils.actor',
+                        'open-ils.actor.container.item.create', 
+                        egCore.auth.token(), 'copy', item
+                    );
+                }).then(function(resp) {
                     // HACK: add the IDs of the added items so that the size
                     // of the view list will grow (and update any UI looking at
                     // the list size).  The data stored is inconsistent, but since