LP#1946531: use batch method to add users to bucket via User Buckets UI
authorJeff Davis <jeff.davis@bc.libraries.coop>
Wed, 11 May 2022 22:55:21 +0000 (15:55 -0700)
committerJane Sandberg <js7389@princeton.edu>
Thu, 19 May 2022 23:56:57 +0000 (17:56 -0600)
Signed-off-by: Jeff Davis <jeff.davis@bc.libraries.coop>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/web/js/ui/default/staff/circ/patron/bucket/app.js

index e183683..d0e7c98 100644 (file)
@@ -84,25 +84,26 @@ function($scope,  $location,  $q,  $timeout,  $uibModal,
         if (recs.length == 0) return;
         bucketSvc.bucketNeedsRefresh = true;
 
-        angular.forEach(recs,
-            function(rec) {
-                var item = new egCore.idl.cubi();
-                item.bucket(bucketSvc.currentBucket.id());
-                item.target_user(rec.id);
-                $scope.removeFromPendingList(rec.id);
-                egCore.net.request(
-                    'open-ils.actor',
-                    'open-ils.actor.container.item.create', 
-                    egCore.auth.token(), 'user', item, 1
-                ).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
-                    // we are forcing a bucket refresh on the next rendering of 
-                    // the view pane, the list will be repaired.
-                    bucketSvc.currentBucket.items().push(resp);
-                });
+        var ids = recs.map(function(rec) {
+            $scope.removeFromPendingList(rec.id);
+            return rec.id;
+        });
+
+        egCore.net.request(
+            'open-ils.actor',
+            'open-ils.actor.container.item.create.batch',
+            egCore.auth.token(), 'user',
+            bucketSvc.currentBucket.id(), ids
+        ).then(
+            null, // complete
+            null, // error
+            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
+                // we are forcing a bucket refresh on the next rendering of
+                // the view pane, the list will be repaired.
+                bucketSvc.currentBucket.items().push(resp);
             }
         );
         //re-draw the pending list