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 35 36 37 38 39 40 41 42 43 44 45 | 4x 4x 4x 4x 4x 4x 8x 8x 8x 8x 8x 10x 10x 2x 2x 1x | import { ChangeDetectionStrategy, Component, DestroyRef, computed, inject, input, output } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { InworkItem } from '@drevo-web/shared';
import { ConfirmationService, IconButtonComponent, IconComponent } from '@drevo-web/ui';
import { filter } from 'rxjs';
const SECONDS_PER_MINUTE = 60;
@Component({
selector: 'app-inwork-item',
imports: [IconComponent, IconButtonComponent],
templateUrl: './inwork-item.component.html',
styleUrl: './inwork-item.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InworkItemComponent {
private readonly destroyRef = inject(DestroyRef);
private readonly confirmationService = inject(ConfirmationService);
readonly item = input.required<InworkItem>();
readonly isOwn = input(false);
readonly cancelEditing = output<string>();
readonly ageMinutes = computed(() => Math.max(1, Math.floor(this.item().age / SECONDS_PER_MINUTE)));
readonly editType = computed(() => (this.item().id > 0 ? 'ред.' : 'нов.'));
onCancel(): void {
this.confirmationService
.open({
title: 'Отменить редактирование?',
message: `Метка редактирования статьи «${this.item().title}» будет снята.`,
buttons: [
{ key: 'confirm', label: 'Да', accent: 'primary' },
{ key: 'cancel', label: 'Нет' },
],
})
.pipe(
filter(result => result === 'confirm'),
takeUntilDestroyed(this.destroyRef),
)
.subscribe(() => this.cancelEditing.emit(this.item().title));
}
}
|