Conversation
| imports: [ | ||
| CommonModule, | ||
| ], | ||
| declarations: [CellHandlerComponent], |
There was a problem hiding this comment.
put back formatting.
It should be autoformatted on save
| if (e.hasChanges('status')) { | ||
| if (e.state.status === 'endBatch' && this.endBatchEdit) { | ||
| this.endBatchEdit(); | ||
| this.endBatchEdit = null; |
There was a problem hiding this comment.
Check if this will break something
| if (this.parentHost) { | ||
| this.parentHost.column.children.push(column); | ||
| if (this.parentHost.column.children) { | ||
| this.parentHost.column.children.push(column); |
There was a problem hiding this comment.
actually you can replace these lines with
this.parentHost.column.children?.push(column);
| .reduce((memo, key) => { | ||
| memo[key] = column[key]; | ||
| .filter(key => !isUndefined(this.key) && Object.prototype.hasOwnProperty.call(column, key)) | ||
| .reduce((memo: any, key: string) => { |
There was a problem hiding this comment.
memo isn't any.
{ [key: string]: Column } if i got this right
| const { column } = this.selfHost; | ||
| if (column && column.source === 'template') { | ||
| this.columnList.delete(column.key); | ||
| if (!(column && column.source === 'template')) { |
There was a problem hiding this comment.
!column || column.source !== 'template' is more readable, as for me.
If there's no column OR coumn source is not template.
Same thing with column.key.
Btw, why you even need to change this condition?
if (column && column.key && column.source === 'template') {
this.columnList.delete(column.key);
}| context.width = host.clientWidth; | ||
| context.height = host.clientHeight; | ||
| if(host) { | ||
| context.width = host.clientWidth; |
There was a problem hiding this comment.
You can remove if (host) condition
context.width = host?.clientWidth;
context.height = host?.clientHeight;| if (target.column.type !== 'row-expand') { | ||
| if (this.toggleStatus.canExecute(target.row)) { | ||
| this.toggleStatus.execute(target.row); | ||
| const timestampNewValue = timestamp.newValue ?? 0; |
There was a problem hiding this comment.
it's better to add delay variable here
const delay = (timestamp.newValue || 0) - (timestamp.oldValue || 0);
if (firstClickTarget === target && delay <= dblClickInterval) {
...
}| @Input('q-grid-core-index') viewIndex: number; | ||
| @Input('q-grid-core-tr') model: any; | ||
| @Input('q-grid-core-source') source; | ||
| @Input('q-grid-core-source') source: string; |
There was a problem hiding this comment.
type BoxParts = keyof { body: Bag; head: Bag; foot: Bag };
OR
type BoxParts = 'body' | 'head' | 'foot';
...
@Input('q-grid-core-source') source: BoxParts;
...
this.plugin.table.box.bag[this.source as BoxParts]Btw, check if there's already an interface that describe this thing { body: Bag; head: Bag; foot: Bag } and use it if exist
| @Input('q-grid-core-index') index: number; | ||
| @Input('q-grid-core-trh') model: any; | ||
| @Input('q-grid-core-source') source; | ||
| @Input('q-grid-core-source') source: string; |
packages/qgrid-ngx/tsconfig.json
Outdated
| @@ -0,0 +1,43 @@ | |||
| { | |||
There was a problem hiding this comment.
Why do we need this file?
There was a problem hiding this comment.
I need it, but the repository does not. Accidental commit.
- Fixed a bug with qgrid-core type
|
|
||
| observeReply(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { |
There was a problem hiding this comment.
e: GridEventArg<SceneState>
|
|
||
| observe(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { |
There was a problem hiding this comment.
e: GridEventArg<SceneState>
| exports: [ | ||
| BodyCoreComponent, | ||
| ], | ||
| exports: [BodyCoreComponent], |
There was a problem hiding this comment.
check indentation.
Should be as before
| export declare class Renderer { | ||
| defaultStrategy: RenderStrategy; | ||
| readonly rows: { left: any[]; right: any[]; mid: any[] }; | ||
| readonly rows: Record<string, any>; |
There was a problem hiding this comment.
I'd create an interface for left, right, mid object and use it here.
export interface RowsPosition {
left: any[];
mid: any[];
right: any[];
}
....
readonly rows: RowsPosition;Because Record<string, ...> could accept any string as a key;
| } | ||
|
|
||
| create(name) { | ||
| create(name: string): Layer | undefined { |
There was a problem hiding this comment.
why undefined? It always return a Layer. If it's not exist it will be created
| @@ -1,4 +1,4 @@ | |||
| import { Injectable } from '@angular/core'; | |||
| import { Component, Injectable } from '@angular/core'; | |||
| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
i'm afraid this would break something.
If you can't assign this method to null create a flag variable and after first visit set it to true;
private onChangesRan = false;
...
ngOnChanges(changes: SimpleChanges) {
if (this.onChangesRan) {
return;
}
if (changes['index']) {
if (this.port.getItemSize()) {
this.onChangesRan = true;
}
}
}| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
It was done like that for the perfomance, vscroll need the best perfomance, and onChanges needs only once, but it calls a lot
| providers: [ | ||
| VscrollService, | ||
| ], | ||
| providers: [VscrollService], |
| } | ||
|
|
||
| transform(data: any[], context: IVscrollContext): ObservableLike<any[]> { | ||
| transform(data: any[], context: IVscrollContext): ObservableLike<any> | PromiseLike<any> | SubjectLike<any> { |
There was a problem hiding this comment.
this method returns items$ which is always SubjectLike<any>, isn't it?
| 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; |
There was a problem hiding this comment.
lets discuss to use Nullable instead of string | null
|
|
||
| observe<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observeReply<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observe<TState>(event: Event<TState>): ObservableEvent<TState>; |
There was a problem hiding this comment.
why we change it to ObservableEvent? it should return the minimal required interface
| import { ColumnView } from '../view/column.view'; | ||
| import { RenderStrategy } from './render.strategy'; | ||
|
|
||
| export interface RowPosition { |
There was a problem hiding this comment.
at least it should be called something like RowsSite
| } | ||
|
|
||
| columnId(index: number, item: ColumnView) { | ||
| columnId(index: number, item: ColumnView): string | undefined { |
| if (e.hasChanges('status')) { | ||
| if (e.state.status === 'endBatch' && this.endBatchEdit) { | ||
| this.endBatchEdit(); | ||
| this.endBatchEdit = null; |
| @Input('q-grid-resize-path') path; | ||
| @Input('q-grid-can-resize') canResize; | ||
| @Input('q-grid-resize-selector') selector; | ||
| @Input('q-grid-resize') key?: string; |
| @Input('q-grid-resize-selector') selector; | ||
| @Input('q-grid-resize') key?: string; | ||
| @Input('q-grid-resize-path') path: string; | ||
| @Input('q-grid-can-resize') canResize: (e: unknown) => boolean; |
There was a problem hiding this comment.
it's defenitly not unknown
|
|
||
| ngOnInit() { | ||
| this.plugin.table.box.bag[this.source].addRow(this); | ||
| this.plugin.table.box.bag[this.source as keyof { body: Bag; head: Bag; foot: Bag }].addRow(this); |
| @Input('q-grid-vscroll-port-y') context: VscrollContext; | ||
|
|
||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
please check if default value not affects
There was a problem hiding this comment.
All ok. It's undefined in the OnInit hook.
There was a problem hiding this comment.
I mean if anywere there is a check on null but god undefined, it can be broken
There was a problem hiding this comment.
All ok. I couldn't find any code that checks if layout is null.
| } | ||
|
|
||
| transform(data: any[], context: IVscrollContext): ObservableLike<any[]> { | ||
| transform(data: any[], context: IVscrollContext): SubjectLike<any> { |
| export declare function binarySearch<T>(list: Array<any>, value: any): number; | ||
| export declare function getTypeName(ctor: new () => any): string; | ||
|
|
||
| export declare type Nullable<T> = T | null; |
There was a problem hiding this comment.
lets have a separate file types.d.ts in utility folder, with all those helper files
| @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; |
| }) | ||
| export class CellHandlerComponent implements OnInit, AfterViewInit { | ||
| private endBatchEdit: () => void; | ||
| private endBatchEdit: (() => void) | null; |
There was a problem hiding this comment.
by default it undefined, and why Nullable is not used here?
| }) | ||
| export class DragDirective { | ||
| @Input('q-grid-drag-data') data: any; | ||
| @Input('q-grid-drag-data') data: unknown; |
| private stateAccessor: StateAccessor, | ||
| private modelBuilder: GridModelBuilder, | ||
| @Inject(DOCUMENT) private document: any, | ||
| @Inject(DOCUMENT) private document: Document, |
There was a problem hiding this comment.
does it work? when you build it in prod?
| ) { } | ||
|
|
||
| find(keys: string | string[]): TemplateLink { | ||
| find(keys: string | string[]): TemplateLink | null { |
|
|
||
| @Input() key = ''; | ||
| @Input() context: any = null; | ||
| @Input() context: unknown = null; |
|
|
||
| markup: { [key: string]: HTMLElement } = {}; | ||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
not sure to remove default values is a good idea
| @Input('q-grid-vscroll-port-y') context: VscrollContext; | ||
|
|
||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
I mean if anywere there is a check on null but god undefined, it can be broken
| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
It was done like that for the perfomance, vscroll need the best perfomance, and onChanges needs only once, but it calls a lot
| 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-label') actualLabel: string; |
There was a problem hiding this comment.
It's not required to be string
| }) | ||
| export class CellHandlerComponent implements OnInit, AfterViewInit { | ||
| private endBatchEdit: () => void; | ||
| private endBatchEdit: Nullable<() => void>; |
There was a problem hiding this comment.
if it's only Nullable but got undefined on start? how lint missed that?
| export class ColumnListService { | ||
| private host = new Lazy(() => { | ||
| const canCopy = (key: string, source, target) => | ||
| const canCopy = (key: string, source: any, target: any) => |
There was a problem hiding this comment.
source, target - Partial<ColumnModel>
| @Input() labelPath: string; | ||
|
|
||
| @Input() itemLabel: (row: any, value?: any) => any; | ||
| @Input() itemLabel: (row: any, value?: unknown) => string; |
| }) | ||
| export class DragDirective { | ||
| @Input('q-grid-drag-data') data: any; | ||
| @Input('q-grid-drag-data') data: string | number | undefined | Node; |
There was a problem hiding this comment.
it sohuld be data or unknown
|
|
||
| $implicit = this; | ||
| element: HTMLElement = null; | ||
| element: HTMLElement; |
There was a problem hiding this comment.
I won't remove default value here also HTMLELement should be changed to Nullable



No description provided.