From 6a3093e244637f5bff4647d46924ddc4ec5c3b20 Mon Sep 17 00:00:00 2001 From: Adam Bowling Date: Wed, 6 Mar 2019 23:06:09 -0500 Subject: [PATCH] LP #1705497 Replaces functionality in web client from legacy XUL client by including a find function for originating acquisition where it exists. Signed-off-by: Adam Bowling Signed-off-by: Tiffany Little Signed-off-by: Chris Sharp --- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index 52d2d021fa..857e522c0f 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -145,6 +145,41 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD itemSvc.manage_reservations([$scope.args.copyBarcode]); } + $scope.findAcquisition = function() { + var acqData; + var promises = []; + $scope.openAcquisitionLineItem([$scope.args.copyId]); + } + + $scope.openAcquisitionLineItem = function (cp_list) { + var hasResults = false; + var promises = []; + + angular.forEach(cp_list, function (copyId) { + promises.push( + egNet.request( + 'open-ils.acq', + 'open-ils.acq.lineitem.retrieve.by_copy_id', + egCore.auth.token(), + copyId + ).then(function (acqData) { + if (acqData) { + if (acqData.a) { + acqData = egCore.idl.toHash(acqData); + var url = '/eg/acq/po/view/' + acqData.purchase_order + '/' + acqData.id; + $timeout(function () { $window.open(url, '_blank') }); + hasResults = true; + } + } + }) + ) + }); + + $q.all(promises).then(function () { + !hasResults ? alert('There is no corresponding purchase order for this item.') : false; + }); + } + $scope.requestItems = function() { itemSvc.requestItems([$scope.args.copyId],[$scope.args.recordId]); } -- 2.11.0