From 378d4871c0f9b19e54ae64d841fa9dd002023e2e Mon Sep 17 00:00:00 2001 From: Arjunlal B Date: Mon, 18 Sep 2023 09:26:08 -0700 Subject: [PATCH] Revert "fix: table component should emit column change when columns are updated (#2399)" This reverts commit 80619ef89f60d290294302a4f9d468d674904068. --- .../src/table/table.component.test.ts | 28 ------------------- .../components/src/table/table.component.ts | 15 ++++------ 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/projects/components/src/table/table.component.test.ts b/projects/components/src/table/table.component.test.ts index 919ea6c7a..a99b7a62c 100644 --- a/projects/components/src/table/table.component.test.ts +++ b/projects/components/src/table/table.component.test.ts @@ -445,34 +445,6 @@ describe('Table component', () => { flush(); })); - test('should emit correctly on column changes', fakeAsync(() => { - const mockColumnConfigsChange = jest.fn(); - const columns = buildColumns(); - const spectator = createHost( - ``, - { - hostProps: { - columnConfigs: columns, - data: buildData(), - selectionMode: TableSelectionMode.Multiple, - mode: TableMode.Flat, - mockColumnConfigsChange: mockColumnConfigsChange - } - } - ); - - // Hiding a column - spectator.component.onHideColumn(columns[0]); - expect(mockColumnConfigsChange).toHaveBeenLastCalledWith( - expect.arrayContaining([ - expect.objectContaining({ ...columns[0], visible: false }), - expect.objectContaining({ ...columns[1] }) - ]) - ); - flush(); - })); - test('should select only selected rows', fakeAsync(() => { const columns = buildColumns(); const rows = buildData(); diff --git a/projects/components/src/table/table.component.ts b/projects/components/src/table/table.component.ts index bbdc995cd..8c4a6e592 100644 --- a/projects/components/src/table/table.component.ts +++ b/projects/components/src/table/table.component.ts @@ -2,8 +2,8 @@ /* eslint-disable @angular-eslint/component-max-inline-declarations */ import { ModalService } from '../modal/modal.service'; import { - TableEditColumnsModalComponent, - TableEditColumnsModalConfig + TableEditColumnsModalConfig, + TableEditColumnsModalComponent } from './columns/table-edit-columns-modal.component'; import { CdkHeaderRow } from '@angular/cdk/table'; import { @@ -35,7 +35,7 @@ import { } from '@hypertrace/common'; import { isNil, without } from 'lodash-es'; import { BehaviorSubject, combineLatest, merge, Observable, Subject } from 'rxjs'; -import { filter, map, switchMap, take } from 'rxjs/operators'; +import { switchMap, take, filter, map } from 'rxjs/operators'; import { FilterAttribute } from '../filtering/filter/filter-attribute'; import { LoadAsyncConfig } from '../load-async/load-async.service'; import { PageEvent } from '../paginator/page.event'; @@ -722,7 +722,7 @@ export class TableComponent this.initialColumnConfigIdWidthMap = new Map(visibleColumns.map(column => [column.id, column.width ?? -1])); this.updateVisibleColumns(visibleColumns); - this.propagateUpdatedColumns(columnConfigurations); + this.columnConfigsSubject.next(columnConfigurations); } private checkColumnWidthCompatibilityOrThrow(width?: TableColumnWidth): void { @@ -827,7 +827,7 @@ export class TableComponent const updatedColumns = this.columnConfigsSubject.value; this.updateVisibleColumns(updatedColumns.filter(c => c.visible)); this.distributeWidthToColumns(TableColumnWidthUtil.getColWidthInPx(column.width)); - this.propagateUpdatedColumns(updatedColumns); + this.columnConfigsSubject.next(updatedColumns); } public showEditColumnsModal(): void { @@ -913,11 +913,6 @@ export class TableComponent return this.hasExpandableRows() ? index - 1 : index; } - private propagateUpdatedColumns(updatedColumns: TableColumnConfigExtended[]): void { - this.columnConfigsSubject.next(updatedColumns); - this.columnConfigsChange.next(updatedColumns); - } - private buildColumnConfigExtendeds(columnConfigs: TableColumnConfig[]): TableColumnConfigExtended[] { const stateColumns = [];