From: Bill Erickson Date: Wed, 6 Mar 2019 19:28:44 +0000 (-0500) Subject: LP1803787 Grid context retains selection; lint X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flp1803787-ang-grid-context-menu-3.2;p=working%2FEvergreen.git 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 --- 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..a43b358e3b 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[]; @@ -57,13 +57,6 @@ export class GridBodyComponent implements OnInit { } handleRowClick($event: any, row: any) { - - if (this.context.disableSelect) { - // Avoid any appearance or click behavior when row - // selection is disabled. - return; - } - const index = this.context.getRowIndex(row); if (this.context.disableMultiSelect) { @@ -94,7 +87,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 +97,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 11a4c876b1..9d61b2ad7d 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 @@ -5,7 +5,7 @@
-
-
@@ -31,7 +31,7 @@
- - - @@ -82,7 +82,7 @@
- @@ -105,31 +105,31 @@