common-ui/src/lib/listing/table-content/table-item/table-item.component.ts
2021-11-22 10:13:18 +02:00

28 lines
932 B
TypeScript

import { ChangeDetectionStrategy, Component, forwardRef, Inject, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { ListingComponent } from '../..';
import { IListable } from '../../models';
import { ListingService } from '../../services';
@Component({
selector: 'iqser-table-item',
templateUrl: './table-item.component.html',
styleUrls: ['./table-item.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TableItemComponent<T extends IListable> implements OnInit {
@Input() entity!: T;
@Input() selectionEnabled = false;
isSelected$!: Observable<boolean>;
constructor(
@Inject(forwardRef(() => ListingComponent)) readonly listingComponent: ListingComponent<T>,
readonly listingService: ListingService<T>,
) {}
ngOnInit(): void {
this.isSelected$ = this.listingService.isSelected$(this.entity);
}
}