-
Notifications
You must be signed in to change notification settings - Fork 27
feature/ts-strict/qgrid-ngx #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
b7850f1
302f960
ae105c4
4622ca5
906a93d
186d19f
de08c7e
b9b36b1
eee4a6f
10f3ead
be22350
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| export declare class FormatService { | ||
| static number(x: number, format: string): string; | ||
| static date(x: Date, format: string): string; | ||
| static currency(x: number, format: string): string; | ||
| static number(x: number, format: string): string | null; | ||
| static date(x: Date, format: string): string | null; | ||
| static currency(x: number, format: string): string | null; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| import { Model } from '../model/model'; | ||
| import { Table } from '../dom/table'; | ||
| import { GridLet } from '../grid/grid.let'; | ||
| import { ObservableLike } from '../rx/rx'; | ||
| import { Event } from '../event/event'; | ||
| import { GridLet } from '../grid/grid.let'; | ||
| import { GridService } from '../grid/grid.service'; | ||
| import { Model } from '../model/model'; | ||
| import { ObservableEvent, ObservableReplyEvent } from '../rx/rx'; | ||
|
|
||
| export interface GridPlugin { | ||
| readonly model: Model; | ||
| readonly table: Table; | ||
| readonly view: GridLet; | ||
| readonly service: GridService; | ||
|
|
||
| observe<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observeReply<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observe<TState>(event: Event<TState>): ObservableEvent<TState>; | ||
|
||
| observeReply<TState>(event: Event<TState>): ObservableReplyEvent<TState>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { RenderStrategy } from './render.strategy'; | |
|
|
||
| export declare class Renderer { | ||
| defaultStrategy: RenderStrategy; | ||
| readonly rows: { left: any[]; right: any[]; mid: any[] }; | ||
| readonly rows: Record<string, any>; | ||
|
||
|
|
||
| constructor(plugin: GridPlugin); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,12 +65,12 @@ export class BodyCoreComponent implements OnInit { | |
| scrollSettings, | ||
| )); | ||
|
|
||
| disposable.add(listener.on('wheel', e => host.wheel(e))); | ||
| disposable.add(listener.on('mouseleave', e => host.mouseLeave(e))); | ||
| disposable.add(listener.on('wheel', (e: WheelEvent) => host.wheel(e))); | ||
| disposable.add(listener.on('mouseleave', (e: WheelEvent) => host.mouseLeave(e))); | ||
| }); | ||
|
|
||
| observeReply(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (model.grid().interactionMode === 'detached') { | ||
| if (e.hasChanges('status')) { | ||
| switch (e.state.status) { | ||
|
|
@@ -86,22 +86,22 @@ export class BodyCoreComponent implements OnInit { | |
| }); | ||
|
|
||
| observe(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (e.hasChanges('status') && e.state.status === 'push') { | ||
| this.cd.markForCheck(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| columnId(index: number, item: ColumnView) { | ||
| columnId(index: number, item: ColumnView): string | undefined { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shorly
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return item.model.key; | ||
| } | ||
|
|
||
| rowId(index: number) { | ||
| rowId(index: number): number { | ||
| return index; | ||
| } | ||
|
|
||
| mapToDataIndex(viewIndex: number) { | ||
| mapToDataIndex(viewIndex: number): number { | ||
| return this.$view.scroll.y.container.position + viewIndex; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,7 @@ import { RowModule } from '../row/row.module'; | |
| VscrollModule, | ||
| RowModule, | ||
| ], | ||
| exports: [ | ||
| BodyCoreComponent, | ||
| ], | ||
| exports: [BodyCoreComponent], | ||
|
||
| }) | ||
| export class BodyModule { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,8 @@ import { TrCoreDirective } from '../row/tr-core.directive'; | |
| selector: '[q-grid-core-td]', | ||
| }) | ||
| export class TdCoreDirective implements DomTd, OnInit, OnDestroy, OnChanges { | ||
| @Input('q-grid-core-value') actualValue: any; | ||
| @Input('q-grid-core-label') actualLabel: any; | ||
| @Input('q-grid-core-value') actualValue: unknown; | ||
| @Input('q-grid-core-label') actualLabel: unknown; | ||
|
||
|
|
||
| @Input('q-grid-core-td') columnView: ColumnView; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,6 @@ export class CellHandlerComponent implements OnInit, AfterViewInit { | |
| if (e.hasChanges('status')) { | ||
| if (e.state.status === 'endBatch' && this.endBatchEdit) { | ||
| this.endBatchEdit(); | ||
| this.endBatchEdit = null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if this will break something
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be reverted |
||
| } | ||
| } | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { GridPlugin } from '../plugin/grid-plugin'; | |
| @Injectable() | ||
| export class ColumnListService { | ||
| private host = new Lazy(() => { | ||
| const canCopy = (key: string, source, target) => | ||
| const canCopy = (key: string, source: any, target: any) => | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. source, target - |
||
| Object.prototype.hasOwnProperty.call(target, key) && !isUndefined(source[key]); | ||
|
|
||
| return new ColumnListHost(this.plugin.model, canCopy, parseFactory); | ||
|
|
@@ -20,27 +20,27 @@ export class ColumnListService { | |
| constructor(private plugin: GridPlugin) { | ||
| } | ||
|
|
||
| add(column: ColumnModel) { | ||
| add(column: ColumnModel): void { | ||
| this.host.instance.add(column); | ||
| } | ||
|
|
||
| copy(target, source) { | ||
| copy(target: any, source: any): void { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any -> |
||
| this.host.instance.copy(target, source); | ||
| } | ||
|
|
||
| generateKey(source) { | ||
| generateKey(source: any): string { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any -> |
||
| return this.host.instance.generateKey(source); | ||
| } | ||
|
|
||
| extract(key, type): ColumnModel { | ||
| extract(key: string, type: string): ColumnModel { | ||
| return this.host.instance.extract(key, type); | ||
| } | ||
|
|
||
| register(column: ColumnModel) { | ||
| register(column: ColumnModel): void { | ||
| this.host.instance.register(column); | ||
| } | ||
|
|
||
| delete(key: string) { | ||
| delete(key: string): void { | ||
| this.host.instance.delete(key); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,7 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
| // We want to update model when ngOntInit is triggered and not in afterViewInit | ||
| // so we apply dirty hack to understand if column is cohort or not. | ||
| const element = this.elementRef.nativeElement as HTMLElement; | ||
| if (element.children.length && element.children.item(0).tagName === 'Q-GRID-COLUMN') { | ||
| if (element.children.length && element.children.item(0)?.tagName === 'Q-GRID-COLUMN') { | ||
| this.type = 'cohort'; | ||
| if (!withKey) { | ||
| this.key = `$cohort-${this.title || guid()}`; | ||
|
|
@@ -142,7 +142,9 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
|
|
||
| if (withKey) { | ||
| if (this.parentHost) { | ||
| this.parentHost.column.children.push(column); | ||
| if (this.parentHost.column.children) { | ||
| this.parentHost.column.children.push(column); | ||
|
||
| } | ||
| } else { | ||
| this.columnList.add(column); | ||
| } | ||
|
|
@@ -152,9 +154,9 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
| const settings = | ||
| Object | ||
| .keys(this) | ||
| .filter(key => !isUndefined(this[key]) && Object.prototype.hasOwnProperty.call(column, key)) | ||
| .reduce((memo, key) => { | ||
| memo[key] = column[key]; | ||
| .filter(key => !isUndefined(this.key) && Object.prototype.hasOwnProperty.call(column, key)) | ||
| .reduce((memo: any, key: string) => { | ||
|
||
| memo[key] = column[key as keyof ColumnModel]; | ||
| return memo; | ||
| }, {}) as ColumnModel; | ||
|
|
||
|
|
@@ -180,8 +182,12 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
|
|
||
| ngOnDestroy() { | ||
| const { column } = this.selfHost; | ||
| if (column && column.source === 'template') { | ||
| this.columnList.delete(column.key); | ||
| if (!(column && column.source === 'template')) { | ||
|
||
| return; | ||
| } | ||
| if(!column.key) { | ||
| return; | ||
| } | ||
| this.columnList.delete(column.key); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,15 +21,15 @@ export class TfCoreDirective implements DomTd, OnInit, OnDestroy { | |
| @Input('q-grid-core-tf') columnView: ColumnView; | ||
|
|
||
| $implicit = this; | ||
| element: HTMLElement = null; | ||
| element: HTMLElement; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to remove default value, please check if there is no null checks for the element anywhere or hasOwnProperty
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I won't remove default value here also HTMLELement should be changed to Nullable |
||
|
|
||
| get value() { | ||
| const column = this.column; | ||
| return this.$view.foot.value(column); | ||
| } | ||
|
|
||
| get label() { | ||
| return this.label; | ||
| return this.value; | ||
| } | ||
|
|
||
| get column(): ColumnModel { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,7 +154,7 @@ export class GridComponent implements OnInit, OnChanges { | |
| private cd: ChangeDetectorRef, | ||
| private stateAccessor: StateAccessor, | ||
| private modelBuilder: GridModelBuilder, | ||
| @Inject(DOCUMENT) private document: any, | ||
| @Inject(DOCUMENT) private document: Document, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it work? when you build it in prod? |
||
| theme: ThemeService, | ||
| ) { | ||
| if (!theme.component) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ import { GridComponent } from './grid.component'; | |
| ], | ||
| imports: [ | ||
| CommonModule, | ||
|
|
||
| BoxModule, | ||
| LayerModule, | ||
| MarkupModule, | ||
|
|
@@ -47,7 +46,7 @@ export class GridModule { | |
| numberPipe: DecimalPipe, | ||
| currencyPipe: CurrencyPipe, | ||
| ) { | ||
| FormatService.date = (x, format) => datePipe.transform(x, format); | ||
| FormatService.date = (x: Date, format: string) => datePipe.transform(x, format); | ||
| FormatService.number = (x, format) => numberPipe.transform(x, format); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why here there is no type? |
||
| FormatService.currency = (x, format) => currencyPipe.transform(x, format); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ export class ThCoreDirective implements DomTd, OnInit, OnDestroy { | |
| $implicit = this; | ||
| element: HTMLElement; | ||
| value: any; | ||
| label: any; | ||
| label: string; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in reality it can be any |
||
|
|
||
| get column(): ColumnModel { | ||
| return this.columnView.model; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,18 +4,18 @@ import { | |
| GridLet, | ||
| Lazy, | ||
| ObservableEvent, | ||
| ObservableLike, | ||
| ObservableReplyEvent, | ||
| } from '@qgrid/core'; | ||
| import { DomTable } from '../dom/dom'; | ||
| import { Grid, GridService } from '../grid/grid'; | ||
| import { GridLet as NgxGridLet } from '../grid/grid-let'; | ||
| import { GridModel } from '../grid/grid-model'; | ||
| import { GridRoot } from '../grid/grid-root'; | ||
| import { GridPlugin as GridPluginInterface } from '@qgrid/core'; | ||
| import { Disposable } from '../infrastructure/disposable'; | ||
|
|
||
| @Injectable() | ||
| export class GridPlugin implements OnDestroy { | ||
| export class GridPlugin implements OnDestroy, GridPluginInterface { | ||
| private serviceLazy = new Lazy(() => this.qgrid.service(this.$root.model)); | ||
|
|
||
| readonly disposable = new Disposable(); | ||
|
|
@@ -45,9 +45,9 @@ export class GridPlugin implements OnDestroy { | |
| ) { | ||
| } | ||
|
|
||
| readonly observe = <TState>(event: Event<TState>): ObservableLike<TState> => new ObservableEvent(event, this.disposable); | ||
| readonly observe = <TState>(event: Event<TState>): ObservableEvent<TState> => new ObservableEvent(event, this.disposable); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please, revert back to ObervableLike |
||
|
|
||
| readonly observeReply = <TState>(event: Event<TState>): ObservableLike<TState> => new ObservableReplyEvent(event, this.disposable); | ||
| readonly observeReply = <TState>(event: Event<TState>): ObservableReplyEvent<TState> => new ObservableReplyEvent(event, this.disposable); | ||
|
|
||
| ngOnDestroy() { | ||
| this.disposable.finalize(); | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets discuss to use Nullable instead of
string | null