All files / app/shared/components/articles-history-item articles-history-item.component.ts

100% Statements 17/17
100% Branches 2/2
100% Functions 4/4
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 354x 4x   4x                 4x 24x 24x 24x 24x   24x 24x   24x     2x 1x         1x 1x      
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
import { RouterLink } from '@angular/router';
import { ArticleHistoryItem } from '@drevo-web/shared';
import { ButtonComponent, FormatTimePipe, IconButtonComponent, StatusIconComponent } from '@drevo-web/ui';
 
@Component({
    selector: 'app-articles-history-item',
    imports: [StatusIconComponent, RouterLink, FormatTimePipe, IconButtonComponent, ButtonComponent],
    templateUrl: './articles-history-item.component.html',
    styleUrl: './articles-history-item.component.scss',
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ArticlesHistoryItemComponent {
    readonly item = input.required<ArticleHistoryItem>();
    readonly selected = input(false);
    readonly selectable = input(false);
    readonly canCompare = input(false);
 
    readonly selectItem = output<ArticleHistoryItem>();
    readonly compare = output<void>();
 
    readonly diffLink = computed(() => ['/history/articles/diff', this.item().versionId]);
 
    onItemClick(): void {
        if (this.selectable()) {
            this.selectItem.emit(this.item());
        }
    }
 
    onCompareClick(event: Event): void {
        event.stopPropagation();
        this.compare.emit();
    }
}