move common properties to IListable
This commit is contained in:
parent
29c267104e
commit
93b5ea7f89
@ -21,6 +21,9 @@ export abstract class ListingComponent<T extends IListable> extends AutoUnsubscr
|
|||||||
readonly noContent$ = this._noContent$;
|
readonly noContent$ = this._noContent$;
|
||||||
readonly sortedDisplayedEntities$ = this._sortedDisplayedEntities$;
|
readonly sortedDisplayedEntities$ = this._sortedDisplayedEntities$;
|
||||||
readonly listingMode$: Observable<ListingMode>;
|
readonly listingMode$: Observable<ListingMode>;
|
||||||
|
/**
|
||||||
|
* @deprecated Use routerLink getter from IListable
|
||||||
|
*/
|
||||||
readonly routerLinkFn?: (entity: T) => string | string[];
|
readonly routerLinkFn?: (entity: T) => string | string[];
|
||||||
|
|
||||||
abstract readonly tableColumnConfigs: readonly TableColumnConfig<T>[];
|
abstract readonly tableColumnConfigs: readonly TableColumnConfig<T>[];
|
||||||
@ -30,8 +33,8 @@ export abstract class ListingComponent<T extends IListable> extends AutoUnsubscr
|
|||||||
* Key used in the *trackBy* function with **ngFor* or **cdkVirtualFor*
|
* Key used in the *trackBy* function with **ngFor* or **cdkVirtualFor*
|
||||||
* and in the default sorting and as the search field
|
* and in the default sorting and as the search field
|
||||||
* @protected
|
* @protected
|
||||||
|
* @deprecated Use searchKey getter from IListable
|
||||||
*/
|
*/
|
||||||
protected abstract readonly _primaryKey: KeysOf<T>;
|
|
||||||
private readonly _listingMode$ = new BehaviorSubject<ListingMode>(ListingModes.table);
|
private readonly _listingMode$ = new BehaviorSubject<ListingMode>(ListingModes.table);
|
||||||
|
|
||||||
protected constructor(protected readonly _injector: Injector) {
|
protected constructor(protected readonly _injector: Injector) {
|
||||||
@ -87,6 +90,6 @@ export abstract class ListingComponent<T extends IListable> extends AutoUnsubscr
|
|||||||
|
|
||||||
@Bind()
|
@Bind()
|
||||||
trackByPrimaryKey(index: number, item: T): unknown {
|
trackByPrimaryKey(index: number, item: T): unknown {
|
||||||
return item[this._primaryKey];
|
return item.searchKey ?? item[this._primaryKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
export interface IListable {
|
export interface IListable {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
readonly searchKey?: string;
|
||||||
readonly routerLink?: string;
|
readonly routerLink?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
* // Expect: "name | setName | someKeys | someFn"
|
* // Expect: "name | setName | someKeys | someFn"
|
||||||
* type Keys = KeysOf<Object>;
|
* type Keys = KeysOf<Object>;
|
||||||
*/
|
*/
|
||||||
export type KeysOf<T> = {
|
export type KeysOf<Type, ExtendedType = unknown> = {
|
||||||
[K in keyof T]: K;
|
[Key in keyof Type]: Type[Key] extends ExtendedType ? Key : never;
|
||||||
}[keyof T];
|
}[keyof Type];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ValuesOf
|
* ValuesOf
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user