-
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 6 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 |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import { | |
| selector: '[q-grid-dirty]', | ||
| }) | ||
| export class DirtyDirective implements OnChanges { | ||
| @Input('q-grid-dirty') trigger: any; | ||
| @Input('q-grid-dirty') trigger: unknown; | ||
|
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. not sure that public properties will work with |
||
|
|
||
| constructor(private cd: ChangeDetectorRef) { | ||
| } | ||
|
|
||
| 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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { | |
| ColumnModelWidthMode, | ||
| guid, | ||
| isUndefined, | ||
| Row, | ||
| } from '@qgrid/core'; | ||
| import { ColumnListService } from '../column-list/column-list.service'; | ||
| import { GridPlugin } from '../plugin/grid-plugin'; | ||
|
|
@@ -73,17 +74,17 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
|
|
||
| @Input() index: number; | ||
|
|
||
| @Input() label: ((row: any, value?: any) => any) | any; | ||
| @Input() label: ((row: Row, value?: unknown) => string) | 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. what is Row? |
||
| @Input() labelPath: string; | ||
|
|
||
| @Input() itemLabel: (row: any, value?: any) => any; | ||
| @Input() itemLabel: (row: any, value?: unknown) => 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. not sure about string |
||
| @Input() itemFormat: string; | ||
| @Input() itemType: string; | ||
|
|
||
| @Input() value: (row: any, value?: any) => any; | ||
| @Input() value: (row: Row, value?: unknown) => 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. why here any and not Row as above? |
||
| @Input() path: string; | ||
|
|
||
| @Input() compare: (x: any, y: any) => number; | ||
| @Input() compare: (x: number, y: number) => number; | ||
|
|
||
| @Input() trueValue: any; | ||
| @Input() falseValue: any; | ||
|
|
@@ -109,7 +110,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 +143,7 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
|
|
||
| if (withKey) { | ||
| if (this.parentHost) { | ||
| this.parentHost.column.children.push(column); | ||
| this.parentHost.column.children?.push(column); | ||
| } else { | ||
| this.columnList.add(column); | ||
| } | ||
|
|
@@ -152,9 +153,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: { [key: string]: ColumnModel }, key: string) => { | ||
| memo[key] = column[key as keyof ColumnModel]; | ||
| return memo; | ||
| }, {}) as ColumnModel; | ||
|
|
||
|
|
@@ -180,7 +181,7 @@ export class ColumnComponent implements OnInit, OnDestroy, OnChanges { | |
|
|
||
| ngOnDestroy() { | ||
| const { column } = this.selfHost; | ||
| if (column && column.source === 'template') { | ||
| if (column && column.key && column.source === 'template') { | ||
|
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 |
||
| this.columnList.delete(column.key); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { GridPlugin } from '../plugin/grid-plugin'; | |
| selector: '[q-grid-drag]', | ||
| }) | ||
| export class DragDirective { | ||
| @Input('q-grid-drag-data') data: any; | ||
| @Input('q-grid-drag-data') data: unknown; | ||
|
||
| @Input('q-grid-drag-effect') effect: undefined | 'move'; | ||
| @Input('q-grid-drag') drag: Command; | ||
| @Input('q-grid-drop-area') area: string; | ||
|
|
@@ -38,7 +38,9 @@ export class DragDirective { | |
|
|
||
| if (this.drag.canExecute(eventArg) === false) { | ||
| e.preventDefault(); | ||
| transfer.effectAllowed = 'none'; | ||
| if (transfer) { | ||
| transfer.effectAllowed = 'none'; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -50,8 +52,10 @@ export class DragDirective { | |
|
|
||
| this.elementRef.nativeElement.classList.add(`${GRID_PREFIX}-drag`); | ||
|
|
||
| transfer.setData(DragService.mimeType, DragService.encode(data)); | ||
| transfer.effectAllowed = this.effect || 'move'; | ||
| if(transfer) { | ||
| transfer.setData(DragService.mimeType, DragService.encode(data)); | ||
| transfer.effectAllowed = this.effect || 'move'; | ||
| } | ||
|
|
||
| DragService.data = data; | ||
| DragService.area = this.area; | ||
|
|
@@ -78,8 +82,5 @@ export class DragDirective { | |
| this.elementRef.nativeElement.classList.remove(`${GRID_PREFIX}-drag`); | ||
|
|
||
| DragService.data = null; | ||
| DragService.area = null; | ||
| DragService.element = null; | ||
| DragService.startPosition = null; | ||
| } | ||
| } | ||

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