Skip to content

Conversation

@FinalButterfly
Copy link
Contributor

No description provided.

imports: [
CommonModule,
],
declarations: [CellHandlerComponent],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if this will break something

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be reverted

if (this.parentHost) {
this.parentHost.column.children.push(column);
if (this.parentHost.column.children) {
this.parentHost.column.children.push(column);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here for BoxParts

@@ -0,0 +1,43 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it, but the repository does not. Accidental commit.


observeReply(model.sceneChanged)
.subscribe(e => {
.subscribe((e: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e: GridEventArg<SceneState>


observe(model.sceneChanged)
.subscribe(e => {
.subscribe((e: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e: GridEventArg<SceneState>

exports: [
BodyCoreComponent,
],
exports: [BodyCoreComponent],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component isn't used

ngOnChanges(changes: SimpleChanges) {
if (changes['index']) {
if (this.port.getItemSize()) {
this.ngOnChanges = null;
Copy link
Contributor

@Dalantren Dalantren May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for onChanges here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation

}

transform(data: any[], context: IVscrollContext): ObservableLike<any[]> {
transform(data: any[], context: IVscrollContext): ObservableLike<any> | PromiseLike<any> | SubjectLike<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

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


observe<TState>(event: Event<TState>): ObservableLike<TState>;
observeReply<TState>(event: Event<TState>): ObservableLike<TState>;
observe<TState>(event: Event<TState>): ObservableEvent<TState>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least it should be called something like RowsSite

}

columnId(index: number, item: ColumnView) {
columnId(index: number, item: ColumnView): string | undefined {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorly string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not possible. Have to specify it as a union.
image

if (e.hasChanges('status')) {
if (e.state.status === 'endBatch' && this.endBatchEdit) {
this.endBatchEdit();
this.endBatchEdit = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be reverted

@Input('q-grid-resize-path') path;
@Input('q-grid-can-resize') canResize;
@Input('q-grid-resize-selector') selector;
@Input('q-grid-resize') key?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ? here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyof typeof bag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bag does not contain said fields, so it's not possible to use keyof typeof, unless we add the said fields into the exported Bag class.
image

@Input('q-grid-vscroll-port-y') context: VscrollContext;

layout: VscrollLayout = null;
layout: VscrollLayout;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if default value not affects

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All ok. It's undefined in the OnInit hook.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if anywere there is a check on null but god undefined, it can be broken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

back to ObservableLike

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about that

})
export class CellHandlerComponent implements OnInit, AfterViewInit {
private endBatchEdit: () => void;
private endBatchEdit: (() => void) | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure

private stateAccessor: StateAccessor,
private modelBuilder: GridModelBuilder,
@Inject(DOCUMENT) private document: any,
@Inject(DOCUMENT) private document: Document,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work? when you build it in prod?

) { }

find(keys: string | string[]): TemplateLink {
find(keys: string | string[]): TemplateLink | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable


@Input() key = '';
@Input() context: any = null;
@Input() context: unknown = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure


markup: { [key: string]: HTMLElement } = {};
layout: VscrollLayout = null;
layout: VscrollLayout;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure to remove default values is a good idea

@Input('q-grid-vscroll-port-y') context: VscrollContext;

layout: VscrollLayout = null;
layout: VscrollLayout;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not required to be string

})
export class CellHandlerComponent implements OnInit, AfterViewInit {
private endBatchEdit: () => void;
private endBatchEdit: Nullable<() => void>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source, target - Partial<ColumnModel>

@Input() labelPath: string;

@Input() itemLabel: (row: any, value?: any) => any;
@Input() itemLabel: (row: any, value?: unknown) => string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about string

})
export class DragDirective {
@Input('q-grid-drag-data') data: any;
@Input('q-grid-drag-data') data: string | number | undefined | Node;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it sohuld be data or unknown


$implicit = this;
element: HTMLElement = null;
element: HTMLElement;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants