From c5efb4475b0f06bfd43664fba6d8555c6d6bb2ca Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 6 Mar 2019 14:28:44 -0500 Subject: [PATCH] LP1803787 Grid context retains selection; lint During right-click (context-menu click) if the currently focused row is already selected, avoid modifying the selection. If it's not, then select the focused row only. Minor lint, etc. repairs. Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts | 12 ++++++++---- .../src/eg2/src/app/share/grid/grid-toolbar.component.html | 8 +++----- .../src/eg2/src/app/share/grid/grid-toolbar.component.ts | 3 +++ Open-ILS/src/eg2/src/app/share/grid/grid.ts | 7 +++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts index 0486b88923..8d96401674 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts @@ -13,7 +13,7 @@ export class GridBodyComponent implements OnInit { @Input() context: GridContext; - // Track the context menus so we can manually close them + // Track the context menus so we can manually close them // when another popover is opened. contextMenus: NgbPopover[]; @@ -94,7 +94,7 @@ export class GridBodyComponent implements OnInit { action.action(this.context.getSelectedRows()); } - // Apply row selection, track the new menu if needed, + // Apply row selection, track the new menu if needed, // manually close any existing open menus, open selected menu. onRowContextClick($event, row: any, contextMenu: NgbPopover) { $event.preventDefault(); // prevent browser context menu @@ -104,14 +104,18 @@ export class GridBodyComponent implements OnInit { return; } - this.handleRowClick($event, row); + if (!this.context.rowIsSelected(row)) { + // If the focused row is not selected, select it. + // Otherwise, avoid modifying the row selection. + this.context.selectOneRow(this.context.getRowIndex(row)); + } const existing = this.contextMenus.filter(m => m === contextMenu)[0]; if (!existing) { this.contextMenus.push(contextMenu); } - // Force any previously opened menus to close, which does + // Force any previously opened menus to close, which does // not naturally occur via context-click. this.contextMenus.forEach(m => m.close()); diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html index cd2bac2854..d35bcafa6d 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html @@ -36,7 +36,9 @@ class="material-icons mat-icon-in-button">playlist_add_check