common-ui/src/lib/listing/table-column-name/table-column-name.component.ts
2024-06-19 13:05:12 +03:00

30 lines
1.2 KiB
TypeScript

import { AsyncPipe, NgClass } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, Optional } from '@angular/core';
import { MatIcon } from '@angular/material/icon';
import { MatTooltip } from '@angular/material/tooltip';
import { TranslateModule } from '@ngx-translate/core';
import { SortingOrders, SortingService } from '../../sorting';
import { KeysOf } from '../../utils';
import { Id, IListable } from '../models';
@Component({
selector: 'iqser-table-column-name [label]',
templateUrl: './table-column-name.component.html',
styleUrls: ['./table-column-name.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatIcon, MatTooltip, TranslateModule, AsyncPipe, NgClass],
})
export class TableColumnNameComponent<T extends IListable<PrimaryKey>, PrimaryKey extends Id = T['id']> {
readonly sortingOrders = SortingOrders;
@Input() label!: string;
@Input() sortByKey?: KeysOf<T>;
@Input() class?: string;
@Input() leftIcon?: string;
@Input() rightIcon?: string;
@Input() rightIconTooltip?: string;
constructor(@Optional() readonly sortingService: SortingService<T>) {}
}