LP#1932203: serialize requests on Edit Due Date in Items Out tab
[evergreen-equinox.git] / Open-ILS / web / js / ui / default / staff / circ / patron / items_out.js
index eaf53f3..b2988c5 100644 (file)
@@ -354,11 +354,12 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc ,
                     $scope.ok = function(args) {
                         var due = $scope.args.due_date.toISOString();
                         console.debug("applying due date of " + due);
+                        egProgressDialog.open();
 
-                        var promises = [];
+                        var promise = $q.when();
                         angular.forEach(items, function(circ) {
-                            promises.push(
-                                egCore.net.request(
+                            promise = promise.then(function() {
+                                return egCore.net.request(
                                     'open-ils.circ',
                                     'open-ils.circ.circulation.due_date.update',
                                     egCore.auth.token(), circ.id(), due
@@ -368,10 +369,11 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc ,
                                     // date from the modified circulation.
                                     circ.due_date(new_circ.due_date());
                                 })
-                            );
+                            });
                         });
 
-                        $q.all(promises).then(function() {
+                        promise.finally(function() {
+                            egProgressDialog.close();
                             $uibModalInstance.close();
                             provider.refresh();
                         });