From f4a19555f2eca13d0a0bbc1a43d6e0fe25d0555c Mon Sep 17 00:00:00 2001 From: Adam Bowling <abowling@emeralddata.net> 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 <abowling@emeralddata.net> Signed-off-by: Tiffany Little <tlittle@georgialibraries.org> Signed-off-by: Chris Sharp <csharp@georgialibraries.org> --- Open-ILS/src/templates/staff/cat/item/index.tt2 | 3 ++ Open-ILS/src/templates/staff/cat/item/t_list.tt2 | 5 +- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 59 +++++++++++++++++++++--- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/item/index.tt2 b/Open-ILS/src/templates/staff/cat/item/index.tt2 index 0a782812fc..8373049e04 100644 --- a/Open-ILS/src/templates/staff/cat/item/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/index.tt2 @@ -90,6 +90,9 @@ <li><a href ng-click="cancel_transit()">[% l('Cancel Transit') %]</a></li> <li><a href ng-click="update_inventory()">[% l('Update Inventory') %]</a></li> + <p><b>[% l('Show') %]</b></p> + <li><a href ng-click="findAcquisition()">[% l('Originating Acquisition') %]</a></li> + <p><b>[% l('Mark') %]</b></p> <li><a href ng-click="selectedHoldingsDamaged()">[% l('Item as Damaged') %]</a></li> <li><a href ng-click="selectedHoldingsMissing()">[% l('Item as Missing') %]</a></li> diff --git a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 index 7f67e46ded..acf90e4a58 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="Windows-1252"?> <eg-grid id-field="index" idl-class="acp" @@ -40,7 +41,9 @@ label="[% l('Record Holds') %]"></eg-grid-action> <eg-grid-action handler="print_labels" group="[% l('Show') %]" label="[% l('Print Labels') %]"></eg-grid-action> - + <eg-grid-action handler="locateAcquisition" group="[% l('Show') %]" + label="[% l('Originating Acquisition') %]"></eg-grid-action> + <eg-grid-action handler="selectedHoldingsDamaged" group="[% l('Mark') %]" label="[% l('Item as Damaged') %]"></eg-grid-action> <eg-grid-action handler="selectedHoldingsMissing" group="[% l('Mark') %]" 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 19e45f921a..26f21ba16e 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 @@ -52,8 +52,8 @@ angular.module('egItemStatus', * Parent scope for list and detail views */ .controller('SearchCtrl', - ['$scope','$location','$timeout','egCore','egGridDataProvider','egItem', -function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) { + ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', +function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc) { $scope.args = {}; // search args // sub-scopes (search / detail-view) apply their version @@ -100,6 +100,41 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) }]); } + $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]); } @@ -244,10 +279,11 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) ['$scope','$q','$routeParams','$location','$timeout','$window','egCore', 'egGridDataProvider','egItem','egUser','$uibModal','egCirc','egConfirmDialog', 'egProgressDialog', 'ngToast', -function($scope , $q , $routeParams , $location , $timeout , $window , egCore , - egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog, - egProgressDialog, ngToast) { - +// function($scope , $q , $routeParams , $location , $timeout , $window , egCore , +// egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog, +// egProgressDialog, ngToast) { + function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog, + egProgressDialog, ngToast) { var copyId = []; var cp_list = $routeParams.idList; if (cp_list) { @@ -392,6 +428,17 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore , itemSvc.add_copies_to_bucket(copy_list); } + $scope.locateAcquisition = function() { + if (gatherSelectedHoldingsIds) { + var cp_list = gatherSelectedHoldingsIds(); + if (cp_list) { + if (cp_list.length > 0) { + $scope.openAcquisitionLineItem(cp_list); + } + } + } + } + $scope.update_inventory = function() { var copy_list = gatherSelectedHoldingsIds(); itemSvc.updateInventory(copy_list, $scope.gridControls.allItems()).then(function(res) { -- 2.11.0