import { ChangeDetectionStrategy, Component, computed, EventEmitter, Input, Optional, Output, TemplateRef } from '@angular/core'; import { ActionConfig, ButtonConfig, SearchPosition, SearchPositions } from './models'; import { IListable } from '../models'; import { IconButtonTypes } from '../../buttons'; import { SearchService } from '../../search'; import { FilterService } from '../../filtering'; import { List } from '../../utils'; import { toSignal } from '@angular/core/rxjs-interop'; @Component({ selector: 'iqser-page-header', templateUrl: './page-header.component.html', styleUrls: ['./page-header.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class PageHeaderComponent { readonly searchPositions = SearchPositions; readonly iconButtonTypes = IconButtonTypes; @Input() pageLabel?: string; @Input() searchInputId?: string; @Input() showCloseButton = false; @Input() hideResetButton = false; @Input() actionConfigs?: List; @Input() buttonConfigs?: List; @Input() viewModeSelection?: TemplateRef; @Input() searchPlaceholder?: string; @Input() searchWidth?: number | 'full'; @Input() helpModeKey?: 'dossier' | 'document'; @Input() searchPosition: SearchPosition = SearchPositions.afterFilters; @Output() readonly closeAction = new EventEmitter(); readonly filters; readonly searchValue; readonly showResetFilters; constructor(@Optional() readonly filterService: FilterService, @Optional() readonly searchService: SearchService) { this.filters = computed(() => this.filterService.filterGroups().filter(fG => fG.icon)); this.searchValue = toSignal(this.searchService.valueChanges$); this.showResetFilters = computed(() => { return this.filterService.showResetFilters() || this.searchValue(); }); } get filterHelpModeKey() { return this.helpModeKey ? `filter_${this.helpModeKey}_list` : ''; } resetFilters(): void { this.filterService.reset(); this.searchService.reset(); } trackByLabel(_index: number, item: K): string | undefined { return item.label; } }