From a30cdce30a3b78e2c03a19dad6ace9bec40217f9 Mon Sep 17 00:00:00 2001 From: Maximilian Koeller Date: Thu, 2 May 2024 15:53:43 +0200 Subject: [PATCH] refactor: add missing internal types pt 2 --- .../src/lib/components/body/body-cell.component.ts | 12 ++++++------ .../body/body-group-header.directive.spec.ts | 2 -- .../components/body/body-row-wrapper.component.ts | 9 +++++---- .../src/lib/components/body/body.component.ts | 6 +++--- .../src/lib/components/datatable.component.ts | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts b/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts index e8cfa528b..22293549d 100644 --- a/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts @@ -167,7 +167,7 @@ export class DataTableBodyCellComponent imp this.sortDir = this.calcSortDir(val); } - get sorts(): any[] { + get sorts(): SortPropDir[] { return this._sorts; } @@ -199,7 +199,7 @@ export class DataTableBodyCellComponent imp ghostLoaderTemplate: ViewContainerRef; @HostBinding('class') - get columnCssClasses(): any { + get columnCssClasses(): string { let cls = 'datatable-body-cell'; if (this.column.cellClass) { if (typeof this.column.cellClass === 'string') { @@ -268,7 +268,7 @@ export class DataTableBodyCellComponent imp return height + 'px'; } - sanitizedValue: any; + sanitizedValue: string; value: any; sortDir: SortDirection; isFocused = false; @@ -276,7 +276,7 @@ export class DataTableBodyCellComponent imp cellContext: CellContext; private _isSelected: boolean; - private _sorts: any[]; + private _sorts: SortPropDir[]; private _column: TableColumn; private _row: RowOrGroup; private _group: TRow[]; @@ -429,7 +429,7 @@ export class DataTableBodyCellComponent imp return; } - const sort = sorts.find((s: any) => s.prop === this.column.prop); + const sort = sorts.find(s => s.prop === this.column.prop); if (sort) { return sort.dir as SortDirection; @@ -447,7 +447,7 @@ export class DataTableBodyCellComponent imp this.treeAction.emit(this.row); } - calcLeftMargin(column: any, row: RowOrGroup) { + calcLeftMargin(column: TableColumn, row: RowOrGroup) { const levelIndent = column.treeLevelIndent != null ? column.treeLevelIndent : 50; return column.isTreeColumn ? (row as TRow).level * levelIndent : 0; } diff --git a/projects/ngx-datatable/src/lib/components/body/body-group-header.directive.spec.ts b/projects/ngx-datatable/src/lib/components/body/body-group-header.directive.spec.ts index 18dbf23e4..cc5aaf71b 100644 --- a/projects/ngx-datatable/src/lib/components/body/body-group-header.directive.spec.ts +++ b/projects/ngx-datatable/src/lib/components/body/body-group-header.directive.spec.ts @@ -19,7 +19,6 @@ class TestFixtureComponent {} describe('DatatableGroupHeaderDirective', () => { let fixture: ComponentFixture; let component: TestFixtureComponent; - let element: any; // provide our implementations or mocks to the dependency injector beforeEach(() => { @@ -33,7 +32,6 @@ describe('DatatableGroupHeaderDirective', () => { TestBed.compileComponents().then(() => { fixture = TestBed.createComponent(TestFixtureComponent); component = fixture.componentInstance; - element = fixture.nativeElement; }); }) ); diff --git a/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts b/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts index 3fa8e1fec..fe6fb5417 100644 --- a/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts @@ -12,11 +12,12 @@ import { Output } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; -import { RowOrGroup } from "../../types/group.type"; +import { Group, RowOrGroup } from '../../types/group.type'; import { NgStyle } from '@angular/common'; import { RowDetailContext } from '../../types/detail-context.type'; import { GroupContext } from '../../types/cell-context.type'; import { DatatableGroupHeaderDirective } from './body-group-header.directive'; +import { DatatableRowDetailDirective } from '../row-detail/row-detail.directive'; @Component({ selector: 'datatable-row-wrapper', @@ -51,12 +52,12 @@ import { DatatableGroupHeaderDirective } from './body-group-header.directive'; }) export class DataTableRowWrapperComponent implements DoCheck, OnInit { @Input() innerWidth: number; - @Input() rowDetail: any; + @Input() rowDetail: DatatableRowDetailDirective; @Input() groupHeader: DatatableGroupHeaderDirective; @Input() offsetX: number; - @Input() detailRowHeight: any; + @Input() detailRowHeight: number; @Input() row: RowOrGroup; - @Input() groupedRows: any; + @Input() groupedRows: Group[]; @Input() disableCheck: (row: RowOrGroup) => boolean; @Output() rowContextmenu = new EventEmitter<{ event: MouseEvent; row: RowOrGroup }>(false); diff --git a/projects/ngx-datatable/src/lib/components/body/body.component.ts b/projects/ngx-datatable/src/lib/components/body/body.component.ts index 6b8977660..5583afa16 100644 --- a/projects/ngx-datatable/src/lib/components/body/body.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body.component.ts @@ -205,10 +205,10 @@ export class DataTableBodyComponent boolean; - @Input() displayCheck: any; + @Input() displayCheck: (row: TRow, column?: TableColumn, value?: any) => boolean; @Input() trackByProp: string; @Input() rowClass: NgClass['ngClass']; - @Input() groupedRows: any; + @Input() groupedRows: Group[]; @Input() groupExpansionDefault: boolean; @Input() innerWidth: number; @Input() groupRowsBy: keyof TRow; @@ -967,7 +967,7 @@ export class DataTableBodyComponent[]): row is Group[]; protected isGroup(row: RowOrGroup): row is Group; protected isGroup(row: RowOrGroup | RowOrGroup[]): boolean { - return this.groupedRows; + return !!this.groupedRows; } protected isRow(row: RowOrGroup): row is TRow { diff --git a/projects/ngx-datatable/src/lib/components/datatable.component.ts b/projects/ngx-datatable/src/lib/components/datatable.component.ts index c65439726..46d842d6b 100644 --- a/projects/ngx-datatable/src/lib/components/datatable.component.ts +++ b/projects/ngx-datatable/src/lib/components/datatable.component.ts @@ -394,7 +394,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterVie * return row.name !== 'Ethel Price'; * } */ - @Input() displayCheck: (row: TRow, column?: any, value?: any) => boolean; + @Input() displayCheck: (row: TRow, column?: TableColumn, value?: any) => boolean; /** * A boolean you can use to set the detault behaviour of rows and groups