From: Bill Erickson Date: Wed, 23 Jan 2019 17:09:18 +0000 (-0500) Subject: LP1808268 eg2 grid action disableOnRows sanity check X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=795c2f3c93356059439788e32950e767be343d43;p=evergreen%2Fmasslnc.git LP1808268 eg2 grid action disableOnRows sanity check The === null test for determining if a disableOnRows handler was set was not broad enough to capture undefined values. This commit changes it to a more generic if() test to cover null/undefined. Also, instead of creating a dummy function in the action, the testing code checks for the presence of the function at run time. Apply a fix to an ng-lint warning introduced by this series of commits in the sandbox code. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts index 85211e6868..0a3337633d 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts @@ -31,9 +31,7 @@ export class GridToolbarActionComponent implements OnInit { const action = new GridToolbarAction(); action.label = this.label; action.action = this.action; - - action.disableOnRows = (this.disableOnRows === null) ? - (rows: any[]) => false : this.disableOnRows; + action.disableOnRows = this.disableOnRows; this.grid.context.toolbarActions.push(action); } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts index 93df40279b..399a4c7211 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts @@ -42,7 +42,10 @@ export class GridToolbarComponent implements OnInit { } shouldDisableAction(action: GridToolbarAction) { - return action.disableOnRows(this.gridContext.getSelectedRows()); + if (action.disableOnRows) { + return action.disableOnRows(this.gridContext.getSelectedRows()); + } + return false; } printHtml() { diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 03895219a4..97605998f4 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -113,7 +113,7 @@ export class SandboxComponent implements OnInit { }; this.complimentEvergreen = (rows: IdlObject[]) => alert('Evergreen is great!'); - this.notOneSelectedRow = (rows: IdlObject[]) => (rows.length != 1); + this.notOneSelectedRow = (rows: IdlObject[]) => (rows.length !== 1); }