LP #1705497 Replaces functionality in web client from legacy
authorAdam Bowling <abowling@emeralddata.net>
Wed, 6 Mar 2019 08:47:47 +0000 (03:47 -0500)
committerAdam Bowling <abowling@emeralddata.net>
Wed, 6 Mar 2019 08:47:47 +0000 (03:47 -0500)
XUL client by including a find function for originating
acquisition where it exists.

Signed-off-by: Adam Bowling <abowling@emeralddata.net>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index 0a78281..7bd48f5 100644 (file)
@@ -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('Find') %]</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>
index 19e45f9..6420faa 100644 (file)
@@ -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,35 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc)
         }]);
     }
 
+    $scope.findAcquisition = function() {
+        var acqData;
+        var promises = [];
+        promises.push(
+            egCore.pcrud.search('jub', {eg_bib_id: $scope.args.copyId}).then(
+                null,
+                null,
+                function (data) {
+                    acqData = data;
+                }
+            )
+        );
+
+        $q.all(promises).then(function() {
+            if (acqData) {
+                acqData = egCore.idl.toHash(acqData);
+                var url = '/eg/acq/po/view/' + acqData.purchase_order + '/' + acqData.id;
+                $timeout(
+                    function() {
+                        $window.open(url, '_blank')
+                    }).then(
+                        function() {$timeout(function(){$window.close()});}
+                    );
+            } else {
+                alert('There is no corresponding purchase order for this item.');
+            }
+        });
+    }
+
     $scope.requestItems = function() {
         itemSvc.requestItems([$scope.args.copyId]);
     }