From 4c8656c7bbb51660de8ee4c569991f802eb41d39 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 25 Feb 2020 13:24:24 -0500 Subject: [PATCH] LP#1850547: eg-grid: Add ignoreFields support to suppress selected IDL-generated grid fields This adds an ignoreFields attribute to eg-grid to specify IDL fields that should not be automatically added as columns to the grid. Sponsored-by: Evergreen Community Development Initiative Sponsored-by: Georgia Public Library Service Sponsored-by: Indiana State Library Sponsored-by: C/W MARS Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Tiffany Little Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/grid/grid.component.ts | 10 ++++++++ Open-ILS/src/eg2/src/app/share/grid/grid.ts | 29 ++++++++++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts index 191bec6d94..23996ee26b 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts @@ -80,6 +80,12 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { // the selected fields will be hidden. @Input() hideFields: string; + // comma-separated list of fields to ignore when generating columns + // from the IDL. + // This does not imply all other fields should be available, only + // that the selected fields will be ignored. + @Input() ignoreFields: string; + // When true, only display columns that are declared in the markup // and leave all auto-generated fields hidden. @Input() showDeclaredFieldsOnly: boolean; @@ -152,6 +158,7 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { this.context.rowFlairCallback = this.rowFlairCallback; this.context.disablePaging = this.disablePaging === true; this.context.cellTextGenerator = this.cellTextGenerator; + this.context.ignoredFields = []; if (this.showFields) { this.context.defaultVisibleFields = this.showFields.split(','); @@ -159,6 +166,9 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { if (this.hideFields) { this.context.defaultHiddenFields = this.hideFields.split(','); } + if (this.ignoreFields) { + this.context.ignoredFields = this.ignoreFields.split(','); + } if (this.pageOffset) { this.context.pager.offset = this.pageOffset; diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.ts index 678651e8ce..d40ac55eff 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -505,6 +505,7 @@ export class GridContext { cellClassCallback: (row: any, col: GridColumn) => string; defaultVisibleFields: string[]; defaultHiddenFields: string[]; + ignoredFields: string[]; overflowCells: boolean; disablePaging: boolean; showDeclaredFieldsOnly: boolean; @@ -1079,20 +1080,22 @@ export class GridContext { this.idl.classes[this.columnSet.idlClass].fields .filter(field => !field.virtual) .forEach(field => { - const col = new GridColumn(); - col.name = field.name; - col.label = field.label || field.name; - col.idlFieldDef = field; - col.idlClass = this.columnSet.idlClass; - col.datatype = field.datatype; - col.isIndex = (field.name === pkeyField); - col.isAuto = true; - - if (this.showDeclaredFieldsOnly) { - col.hidden = true; - } + if (!this.ignoredFields.filter(ignored => ignored === field.name).length) { + const col = new GridColumn(); + col.name = field.name; + col.label = field.label || field.name; + col.idlFieldDef = field; + col.idlClass = this.columnSet.idlClass; + col.datatype = field.datatype; + col.isIndex = (field.name === pkeyField); + col.isAuto = true; + + if (this.showDeclaredFieldsOnly) { + col.hidden = true; + } - this.columnSet.add(col); + this.columnSet.add(col); + } }); } -- 2.11.0