common-ui/src/lib/listing/table-column-name/table-column-name.component.ts
2021-10-06 09:50:13 +03:00

26 lines
985 B
TypeScript

import { ChangeDetectionStrategy, Component, Input, Optional } from '@angular/core';
import { SortingOrders, SortingService } from '../../sorting';
import { KeysOf, Required } from '../../utils';
import { IListable } from '../models';
const ifHasRightIcon = <T extends IListable>(thisArg: TableColumnNameComponent<T>) => !!thisArg.rightIcon;
@Component({
selector: 'iqser-table-column-name',
templateUrl: './table-column-name.component.html',
styleUrls: ['./table-column-name.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TableColumnNameComponent<T extends IListable> {
readonly sortingOrders = SortingOrders;
@Input() @Required() label!: string;
@Input() sortByKey?: KeysOf<T>;
@Input() class?: string;
@Input() leftIcon?: string;
@Input() rightIcon?: string;
@Input() @Required(ifHasRightIcon) rightIconTooltip?: string;
constructor(@Optional() readonly sortingService: SortingService<T>) {}
}