Get table properties from parent component
This commit is contained in:
parent
b1e1bc3f1a
commit
704ea8221e
@ -20,7 +20,11 @@ export abstract class ListingComponent<T extends Listable> extends AutoUnsubscri
|
||||
readonly noMatch$ = this._noMatch$;
|
||||
readonly sortedDisplayedEntities$ = this._sortedDisplayedEntities$;
|
||||
|
||||
// TODO: These should be somewhere in table listing, not generic listing
|
||||
abstract readonly tableColumnConfigs: readonly TableColumnConfig<T>[];
|
||||
readonly tableHeaderLabel?: string;
|
||||
readonly routerLinkFn?: (entity: T) => string | string[];
|
||||
|
||||
/**
|
||||
* Key used in the *trackBy* function with **ngFor* or **cdkVirtualFor*
|
||||
* and in the default sorting and as the search field
|
||||
|
||||
@ -28,20 +28,20 @@ export class TableComponent<T extends Listable> implements OnInit {
|
||||
@Input() actionsTemplate?: TemplateRef<unknown>;
|
||||
@Input() headerTemplate?: TemplateRef<unknown>;
|
||||
@Input() @Required() itemSize!: number;
|
||||
@Input() @Required() tableColumnConfigs!: readonly TableColumnConfig<T>[];
|
||||
@Input() @Required() tableHeaderLabel!: string;
|
||||
@Input() selectionEnabled = false;
|
||||
@Input() hasScrollButton = false;
|
||||
@Input() emptyColumnWidth?: string;
|
||||
@Input() classes?: string;
|
||||
@Input() routerLinkFn?: (entity: T) => string | string[];
|
||||
@Input() noDataText?: string;
|
||||
@Input() noDataIcon?: string;
|
||||
@Input() noDataButtonLabel?: string;
|
||||
@Input() showNoDataButton = false;
|
||||
@Output() readonly noDataAction = new EventEmitter<void>();
|
||||
@Input() noMatchText?: string;
|
||||
@ViewChild(CdkVirtualScrollViewport, { static: true }) private readonly _viewport!: CdkVirtualScrollViewport;
|
||||
routerLinkFn?: (entity: T) => string | string[];
|
||||
tableColumnConfigs!: readonly TableColumnConfig<T>[];
|
||||
tableHeaderLabel?: string; // todo not optional
|
||||
@ViewChild(CdkVirtualScrollViewport, { static: true }) readonly scrollViewport!: CdkVirtualScrollViewport;
|
||||
|
||||
constructor(@Inject(forwardRef(() => ListingComponent)) private _parent: ListingComponent<T>) {}
|
||||
|
||||
@ -50,6 +50,10 @@ export class TableComponent<T extends Listable> implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.tableColumnConfigs = this.listingComponent.tableColumnConfigs;
|
||||
this.tableHeaderLabel = this.listingComponent.tableHeaderLabel;
|
||||
this.routerLinkFn = this.listingComponent.routerLinkFn;
|
||||
|
||||
this._patchConfig();
|
||||
this._setStyles();
|
||||
}
|
||||
@ -59,7 +63,7 @@ export class TableComponent<T extends Listable> implements OnInit {
|
||||
}
|
||||
|
||||
private _setStyles(): void {
|
||||
const element = this._viewport.elementRef.nativeElement;
|
||||
const element = this.scrollViewport.elementRef.nativeElement;
|
||||
this._setColumnsWidth(element);
|
||||
this._setItemSize(element);
|
||||
this._setPadding(element);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user