Skip to content

Commit

Permalink
default to any for TRow in ColumnsBase and directly store columns ins…
Browse files Browse the repository at this point in the history
…tead of using a proxy
  • Loading branch information
volkanceylan committed Oct 20, 2023
1 parent 1b58c7b commit 5abea59
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 1 addition & 2 deletions packages/corelib/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,7 @@ declare namespace SlickTreeHelper {
function setIndents<TItem>(items: TItem[], getId: (x: TItem) => any, getParentId: (x: TItem) => any, setCollapsed?: boolean): void;
function toggleClick<TItem>(e: JQueryEventObject, row: number, cell: number, view: RemoteView<TItem>, getId: (x: TItem) => any): void;
}
declare class ColumnsBase<TRow> {
private items;
declare class ColumnsBase<TRow = any> {
constructor(items: Column<TRow>[]);
valueOf(): Column<TRow>[];
}
Expand Down
33 changes: 19 additions & 14 deletions packages/corelib/src/ui/helpers/slickhelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,22 +806,27 @@ export namespace SlickTreeHelper {
}


export class ColumnsBase<TRow> {
constructor(private items: Column<TRow>[]) {
return new Proxy(this, {
get(target: any, prop) {
if (target[prop])
return target[prop];

var column = tryFirst<Column>(target.items, x =>
x.sourceItem?.name === prop || x.field === prop);
if (column)
return column;
}
}) as any;
export class ColumnsBase<TRow = any> {
constructor(items: Column<TRow>[]) {
(this as any).__items = items;
for (var col of items) {
let id = col.id;
if (id && !(this as any)[id])
(this as any)[id] = col;
}
for (var col of items) {
let id = col.sourceItem?.name;
if (id && !(this as any)[id])
(this as any)[id] = col;
}
for (var col of items) {
let id = col.field;
if (id && !(this as any)[id])
(this as any)[id] = col;
}
}

valueOf(): Column<TRow>[] {
return this.items;
return (this as any).__items;
}
}
3 changes: 1 addition & 2 deletions src/Serenity.Scripts/wwwroot/Serenity.CoreLib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4961,8 +4961,7 @@ declare namespace Serenity {
function setIndents<TItem>(items: TItem[], getId: (x: TItem) => any, getParentId: (x: TItem) => any, setCollapsed?: boolean): void;
function toggleClick<TItem>(e: JQueryEventObject, row: number, cell: number, view: Slick.RemoteView<TItem>, getId: (x: TItem) => any): void;
}
class ColumnsBase<TRow> {
private items;
class ColumnsBase<TRow = any> {
constructor(items: Slick.Column<TRow>[]);
valueOf(): Slick.Column<TRow>[];
}
Expand Down

0 comments on commit 5abea59

Please sign in to comment.