All files / app/features/history/pages/articles-history articles-history.component.ts

93.75% Statements 15/16
50% Branches 1/2
100% Functions 4/4
92.85% Lines 13/14

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 46 47 48 49 50 51 521x       1x 1x   1x   1x                                           1x 6x   6x   6x 6x 6x           6x       1x      
import {
    ArticleHistoryService,
    HistoryFilter,
} from '../../../../services/articles/article-history/article-history.service';
import { ArticleHistoryListComponent } from '../../../../shared/components/article-history-list/article-history-list.component';
import { FiltersSidePanelComponent } from '../../../../shared/components/filters/filters-side-panel/filters-side-panel.component';
import { FilterEntry } from '../../../../shared/models/filter.model';
import { ChangeDetectionStrategy, Component, computed, inject, OnInit } from '@angular/core';
 
const BASE_FILTERS: readonly FilterEntry<HistoryFilter>[] = [
    { key: 'all', label: 'Все' },
    { key: 'unchecked', label: 'Непроверенные' },
    {
        label: 'В работе',
        items: [
            { key: 'unfinished', label: 'Неоконченные' },
            { key: 'unmarked', label: 'Неразмеченные' },
            { key: 'outside_dictionaries', label: 'Вне словников' },
            { key: 'required', label: 'Требующиеся' },
        ],
    },
];
 
@Component({
    selector: 'app-articles-history',
    imports: [ArticleHistoryListComponent, FiltersSidePanelComponent],
    templateUrl: './articles-history.component.html',
    styleUrl: './articles-history.component.scss',
    changeDetection: ChangeDetectionStrategy.OnPush,
    providers: [ArticleHistoryService],
})
export class ArticlesHistoryComponent implements OnInit {
    private readonly service = inject(ArticleHistoryService);
 
    readonly activeFilter = this.service.activeFilter;
 
    readonly filters = computed<readonly FilterEntry<HistoryFilter>[]>(() => {
        Eif (this.service.isAuthenticated()) {
            return [...BASE_FILTERS, { key: 'my', label: 'Мои' }];
        }
        return BASE_FILTERS;
    });
 
    ngOnInit(): void {
        this.service.init();
    }
 
    onFilterChange(filter: HistoryFilter): void {
        this.service.onFilterChange(filter);
    }
}