From 4489629dec1380314aa646ceaf15208bad35ec79 Mon Sep 17 00:00:00 2001
From: Mike Risher <mrisher@catalyte.io>
Date: Tue, 4 Feb 2020 22:42:08 +0000
Subject: [PATCH] lp1792995 wrong row details shown on billing grid

When using the bill grid, if one right clicks on a row and views full
details one is taken to the first selected row.  Make the UI show
full details for the row being right clicked on.  If no row is
clicked on show first selected item's details.

Signed-off-by: Mike Risher <mrisher@catalyte.io>

 Changes to be committed:
	modified:   Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
	modified:   Open-ILS/web/js/ui/default/staff/services/grid.js

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
---
 Open-ILS/web/js/ui/default/staff/circ/patron/bills.js | 8 +++++++-
 Open-ILS/web/js/ui/default/staff/services/grid.js     | 7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
index 25a01d892d..cb10593068 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
@@ -812,9 +812,15 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
 
     // direct the user to the transaction details page
     $scope.showFullDetails = function(all) {
-        if (all[0]) 
+        var lastClicked = $scope.gridControls.contextMenuItem();
+        if (lastClicked) {
+            $location.path('/circ/patron/' + 
+                patronSvc.current.id() + '/bill/' + lastClicked + '/statement');
+        } else if (all[0]) {
             $location.path('/circ/patron/' + 
                 patronSvc.current.id() + '/bill/' + all[0].id + '/statement');
+        }
+            
     }
 
     $scope.activateBill = function(xact) {
diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js
index 6224cb97c8..83a1ebb727 100644
--- a/Open-ILS/web/js/ui/default/staff/services/grid.js
+++ b/Open-ILS/web/js/ui/default/staff/services/grid.js
@@ -281,6 +281,10 @@ angular.module('egGridMod',
                     return grid.columnsProvider;
                 }
 
+                controls.contextMenuItem = function() {
+                    return $scope.contextMenuItem;
+                }
+
                 // link in the control functions
                 controls.selectedItems = function() {
                     return grid.getSelectedItems()
@@ -711,6 +715,9 @@ angular.module('egGridMod',
                     if(s.hasOwnProperty('item')){ break; }
                     e = e.parentElement;
                 }
+                
+                $scope.contextMenuItem = grid.indexValue(s.item);
+                
                 // select the right-clicked row if it is not already selected (lp1776557):
                 if(!$scope.selected[grid.indexValue(s.item)]){ $event.target.click(); }
 
-- 
2.11.0