From 28f955619a2d2d4665ff31c8efd2918a0e7532dd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 29 Mar 2019 16:47:27 +0000 Subject: [PATCH] LP1821382 Grid showDeclaredFieldsOnly option; sort repair. Adds a @Input() showDeclaredFieldsOnly option which tells the grid to avoid showing auto-generated columns by default and only show those declared in the markup. Also repairs a grid column sorting/insert bug where declared columns would be displayed in the wrong order when mixed with auto columns. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- Open-ILS/src/eg2/src/app/share/grid/grid.component.ts | 5 +++++ Open-ILS/src/eg2/src/app/share/grid/grid.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 e1f988ff9f..2b28d2db17 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 @@ -76,6 +76,10 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { // the selected fields will be hidden. @Input() hideFields: string; + // When true, only display columns that are declared in the markup + // and leave all auto-generated fields hidden. + @Input() showDeclaredFieldsOnly: boolean; + // Allow the caller to jump directly to a specific page of // grid data. @Input() pageOffset: number; @@ -133,6 +137,7 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { this.context.showLinkSelectors = this.showLinkSelectors === true; this.context.disableMultiSelect = this.disableMultiSelect === true; this.context.rowFlairIsEnabled = this.rowFlairIsEnabled === true; + this.context.showDeclaredFieldsOnly = this.showDeclaredFieldsOnly; this.context.rowFlairCallback = this.rowFlairCallback; this.context.disablePaging = this.disablePaging === true; if (this.showFields) { 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 fc50f59332..b133d1ad13 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -130,7 +130,7 @@ export class GridColumnSet { if (idx === 0) { this.columns.unshift(col); } else { - this.columns.splice(idx - 1, 0, col); + this.columns.splice(idx, 0, col); } return true; } @@ -444,6 +444,7 @@ export class GridContext { overflowCells: boolean; showLinkSelectors: boolean; disablePaging: boolean; + showDeclaredFieldsOnly: boolean; // Allow calling code to know when the select-all-rows-in-page // action has occurred. @@ -990,6 +991,10 @@ export class GridContext { } } + if (this.showDeclaredFieldsOnly) { + col.hidden = true; + } + this.columnSet.add(col); }); } -- 2.11.0