From: Dan Wells Date: Thu, 11 Oct 2018 13:21:05 +0000 (-0400) Subject: LP#1796971 Wait for call number and copy before loading locations X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=193f06dab36b0636dc9cae2178309400022b6493;p=evergreen%2Fjoelewis.git LP#1796971 Wait for call number and copy before loading locations In cases where add a copy to a call number, we fetch the original call number via async, then attach the new copy to it. Before this commit, however, we were not waiting for the call number fetch promise to resolve, so the copy wasn't there to use for limiting the location load. Since the async request is internal to a loop, one way out is to capture that promise, then make sure it resolves before loading the locations. (We previously returned the copies from the internal function, but that value wasn't being used anyway, so we don't worry about unwrapping the $q.all() when it resolves.) Signed-off-by: Dan Wells Signed-off-by: John Amundson Signed-off-by: Jason Stephenson Signed-off-by: Cesar Velez --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 04b19638af..ae4267495e 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -1525,12 +1525,13 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , * All can be left out and a completely empty vol/copy combo will be vivicated. */ + var promises = []; angular.forEach( data.raw, function (proto) { if (proto.fast_add) $scope.is_fast_add = true; if (proto.callnumber) { - return egCore.pcrud.retrieve('acn', proto.callnumber) + promises.push(egCore.pcrud.retrieve('acn', proto.callnumber) .then(function(cn) { var cp = new itemSvc.generateNewCopy( cn, @@ -1545,7 +1546,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } itemSvc.addCopy(cp) - }); + })); } else { var cn = new egCore.idl.acn(); cn.id( --itemSvc.new_cn_id ); @@ -1612,7 +1613,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } }); - return itemSvc.copies; + return $q.all(promises); } if (data.copies && data.copies.length)