From a5252ebd4c260b4bed3e5ac502999a2a3a012dd9 Mon Sep 17 00:00:00 2001 From: "kim.tran" Date: Fri, 25 Oct 2024 13:37:29 +0200 Subject: [PATCH] fix: custom group selection saved, displaying correct columns on page reload, remove clear column group selection --- .../column-group-selection.component.html | 2 - .../column-group-selection.component.ts | 37 +++++++++---------- .../custom-group-column-selector.component.ts | 2 + .../interactive-data-view.component.html | 1 + 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.html b/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.html index d24689c4..1682e3dc 100644 --- a/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.html +++ b/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.html @@ -2,11 +2,9 @@ diff --git a/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.ts b/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.ts index 70d9a77f..5d49730d 100644 --- a/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.ts +++ b/libs/angular-accelerator/src/lib/components/column-group-selection/column-group-selection.component.ts @@ -20,6 +20,11 @@ export class ColumnGroupSelectionComponent implements OnInit { } set selectedGroupKey(value: string) { this.selectedGroupKey$.next(value) + if (this.selectedGroupKey === this.customGroupKey) { + this.componentStateChanged.emit({ + activeColumnGroupKey: value, + }) + } } columns$ = new BehaviorSubject([]) @@ -51,13 +56,19 @@ export class ColumnGroupSelectionComponent implements OnInit { .filter((value, index, self) => self.indexOf(value) === index && value != null) ) ) - const activeColumns = this.columns.filter((c) => - c.predefinedGroupKeys?.includes(this.selectedGroupKey$.getValue() ?? this.defaultGroupKey) - ) - this.componentStateChanged.emit({ - activeColumnGroupKey: this.selectedGroupKey, - displayedColumns: activeColumns, - }) + if (this.selectedGroupKey === this.customGroupKey) { + this.componentStateChanged.emit({ + activeColumnGroupKey: this.selectedGroupKey, + }) + } else { + const activeColumns = this.columns.filter((c) => + c.predefinedGroupKeys?.includes(this.selectedGroupKey$.getValue() ?? this.defaultGroupKey) + ) + this.componentStateChanged.emit({ + activeColumnGroupKey: this.selectedGroupKey, + displayedColumns: activeColumns, + }) + } } changeGroupSelection(event: { value: string }) { @@ -71,16 +82,4 @@ export class ColumnGroupSelectionComponent implements OnInit { displayedColumns: activeColumns, }) } - - clearGroupSelection() { - let activeColumns = this.columns - if (this.defaultGroupKey) { - activeColumns = this.columns.filter((column) => column.predefinedGroupKeys?.includes(this.defaultGroupKey)) - } - this.groupSelectionChanged.emit({ activeColumns, groupKey: this.defaultGroupKey }) - this.componentStateChanged.emit({ - activeColumnGroupKey: this.defaultGroupKey, - displayedColumns: activeColumns, - }) - } } diff --git a/libs/angular-accelerator/src/lib/components/custom-group-column-selector/custom-group-column-selector.component.ts b/libs/angular-accelerator/src/lib/components/custom-group-column-selector/custom-group-column-selector.component.ts index a9e550f2..36640e64 100644 --- a/libs/angular-accelerator/src/lib/components/custom-group-column-selector/custom-group-column-selector.component.ts +++ b/libs/angular-accelerator/src/lib/components/custom-group-column-selector/custom-group-column-selector.component.ts @@ -39,6 +39,7 @@ export class CustomGroupColumnSelectorComponent implements OnInit { displayedColumns: this._displayedColumns, }) } + @Input() customGroupKey = '' @Input() dialogTitle = '' @Input() dialogTitleKey = '' @Input() openButtonTitle = '' @@ -139,6 +140,7 @@ export class CustomGroupColumnSelectorComponent implements OnInit { frozen: this.frozenActionColumnModel, position: this.actionColumnPositionModel, }, + activeColumnGroupKey: this.customGroupKey, }) } } diff --git a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html index f7033389..d76c4320 100644 --- a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html +++ b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html @@ -51,6 +51,7 @@ *ngIf="layout === 'table'" [columns]="columns" [displayedColumns]="(displayedColumns$ | async) ?? []" + [customGroupKey]="customGroupKey" (columnSelectionChanged)="onColumnSelectionChange($event)" [frozenActionColumn]="frozenActionColumn" [actionColumnPosition]="actionColumnPosition"