diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html
index 07034121..977efe0c 100644
--- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html
+++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html
@@ -1,29 +1,165 @@
-
- @if (works() === null) {
-
- } @else if (works().elements?.length === 0) {
-
-
- groups
- Keine Publikationen gefunden.
-
-
- } @else {
-
-
-
-
-
-
- }
+
+
+
+
+
+
+ @if (loading()) {
+
+ } @else if (works().elements?.length === 0) {
+
+
+ groups
+ Keine Publikationen gefunden.
+
+
+ } @else {
+
+
+
+
+
+
+ }
+
diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss
index 409150fd..9bcf6124 100644
--- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss
+++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss
@@ -1,29 +1,84 @@
-/* ============================================================
- RESULT LAYOUT
- ============================================================ */
-.result-layout {
- display: grid;
- grid-template-columns: 1fr;
- grid-template-areas: 'summary results';
+.page {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+}
+
+.publication-filter-stack {
+ width: 100%;
+}
+
+.publication-filters {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
gap: 0.75rem;
- align-items: start;
+
+ mat-form-field {
+ min-width: 180px;
+ }
+
+ .institution-filter {
+ min-width: 260px;
+ flex: 1 1 260px;
+ }
}
-.search-summary-card {
- grid-area: summary;
+.filter-prefix-icon {
+ margin-right: 0.25rem;
+ color: rgba(0, 0, 0, 0.54);
}
-.results-card {
- grid-area: results;
+.select-search {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.12);
+
+ &__icon {
+ color: rgba(0, 0, 0, 0.54);
+ }
+
+ &__input {
+ flex: 1;
+ border: none;
+ outline: none;
+ font: inherit;
+ background: transparent;
+ }
+
+ &__empty {
+ padding: 0.5rem 0.75rem;
+ color: rgba(0, 0, 0, 0.54);
+ font-size: 0.875rem;
+ }
+}
+
+.reset-filter-btn {
+ display: flex;
+ align-items: center;
+ gap: 0.25rem;
+ height: 40px;
+}
+
+.result-layout {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
}
-.search-summary-card,
.results-card {
background: var(--sg-surface, #ffffff);
border: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12));
box-shadow: none;
- .mat-mdc-card-content {
- padding: 0.75rem;
- }
+ width: 100%;
+}
+
+.results-placeholder {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 0.5rem;
}
diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts
index dd6e11cc..f2d19da0 100644
--- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts
+++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts
@@ -2,40 +2,78 @@ import {
Component,
DestroyRef,
OnInit,
+ effect,
inject,
signal,
computed,
} from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
-import { WeightsSlidersComponent } from '../../../../shared/ui/weights-sliders/weights-sliders.component';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
+import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
+import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatInputModule } from '@angular/material/input';
+import { MatButtonModule } from '@angular/material/button';
+import { MatSelectChange, MatSelectModule } from '@angular/material/select';
+import { workQueryParamKeys } from '../../../../resolvers/work-page.resolver';
+import {
+ MatAutocompleteModule,
+ MatAutocompleteSelectedEvent,
+} from '@angular/material/autocomplete';
+import {
+ catchError,
+ debounceTime,
+ distinctUntilChanged,
+ finalize,
+ map,
+ of,
+ switchMap,
+} from 'rxjs';
+
import { PublicationTableComponent } from '../../../../shared/ui/publication-table/publication-table.component';
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
-import { GenericColumn } from '../../../../shared/ui/data-table/data-table.component';
-import { Work } from '../../../../api/model/work';
import { InseWorksV2ModelWorkPage as WorkPage } from '../../../../api/model/inseWorksV2ModelWorkPage';
import { PaginationService } from '../../../../shared/services/pagination.service';
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
+import { InstitutionsService } from '../../../../api';
import {
- WeightSliderOption,
- WeightsSlidersValue,
- WeightMap,
-} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
-import { viewChild, TemplateRef } from '@angular/core';
+ FilterObserver,
+ SelectedFiltersComponent,
+} from '../../../../shared/ui/selected-filters/selected-filters.component';
+import { translateWorkType } from '../../../../shared/pipes/work-type.pipe';
+import { translateLanguageCode } from '../../../../shared/pipes/language-code.pipe';
import { SortDirection, WorkSortBy, WorksV2Service } from '../../../../api';
import { SearchResultsStateService } from '../search-results-state.service';
+
+interface InstitutionAutocompleteOption {
+ id?: string | null;
+ display_name?: string | null;
+ hint?: string | null;
+ cited_by_count?: number | null;
+ works_count?: number | null;
+ entity_type?: string | null;
+ external_id?: string | null;
+}
+
+const EMPTY_WORK_PAGE: WorkPage = { elements: [], total: 0, page: 0, size: 10 };
+
@Component({
selector: 'app-works-results',
imports: [
MatCardModule,
MatIconModule,
- //WeightsSlidersComponent,
+ MatFormFieldModule,
+ MatInputModule,
+ MatButtonModule,
+ MatSelectModule,
+ MatAutocompleteModule,
+ ReactiveFormsModule,
LoadingComponent,
PublicationTableComponent,
QueryParamPaginatorComponent,
+ SelectedFiltersComponent,
],
templateUrl: './works-results.component.html',
styleUrl: './works-results.component.scss',
@@ -43,199 +81,420 @@ import { SearchResultsStateService } from '../search-results-state.service';
export class KeywordsToWorksResultsComponent implements OnInit {
private readonly state = inject(SearchResultsStateService);
private readonly route = inject(ActivatedRoute);
+ private readonly router = inject(Router);
private readonly worksService = inject(WorksV2Service);
+ private readonly institutionsService = inject(InstitutionsService);
private readonly destroyRef = inject(DestroyRef);
public readonly paginationService = inject(PaginationService);
- readonly works = signal
({
- elements: [],
- total: 0,
- page: 1,
- size: 10,
+
+ loading = signal(false);
+
+ private readonly yearParamKey = workQueryParamKeys.years;
+ private readonly typeParamKey = workQueryParamKeys.types;
+ private readonly languageParamKey = workQueryParamKeys.language;
+ private readonly institutionParamKey = workQueryParamKeys.institutionId;
+ private readonly topicParamKey = workQueryParamKeys.topicId;
+ private readonly pageParamKey = workQueryParamKeys.page;
+
+ // --- Filter option lists ---
+ readonly publicationYearOptions = this.createPublicationYearOptions();
+
+ readonly typeOptions = [
+ { value: 'article', label: 'article' },
+ { value: 'book', label: 'book' },
+ { value: 'book-chapter', label: 'book-chapter' },
+ { value: 'dataset', label: 'dataset' },
+ { value: 'dissertation', label: 'dissertation' },
+ { value: 'editorial', label: 'editorial' },
+ { value: 'erratum', label: 'erratum' },
+ { value: 'letter', label: 'letter' },
+ { value: 'libguides', label: 'libguides' },
+ { value: 'other', label: 'other' },
+ { value: 'paratext', label: 'paratext' },
+ { value: 'peer-review', label: 'peer-review' },
+ { value: 'preprint', label: 'preprint' },
+ { value: 'reference-entry', label: 'reference-entry' },
+ { value: 'report', label: 'report' },
+ { value: 'retraction', label: 'retraction' },
+ { value: 'review', label: 'review' },
+ { value: 'standard', label: 'standard' },
+ { value: 'supplementary-materials', label: 'supplementary-materials' },
+ ];
+
+ readonly languageOptions = [
+ { value: 'en', label: 'Englisch' },
+ { value: 'de', label: 'Deutsch' },
+ ];
+
+ // --- Search-in-panel controls ---
+ readonly yearSearchControl = new FormControl('', { nonNullable: true });
+ readonly typeSearchControl = new FormControl('', { nonNullable: true });
+ readonly languageSearchControl = new FormControl('', { nonNullable: true });
+ readonly institutionSearchControl = new FormControl<
+ string | InstitutionAutocompleteOption
+ >('', { nonNullable: true });
+
+ // Signals instead of plain fields: these are written from inside an RxJS
+ // subscription (outside Angular's normal template-binding update path),
+ // so under OnPush change detection plain field mutation is not guaranteed
+ // to refresh the view. Signals make that update explicit and reliable.
+ readonly institutionLookupLoading = signal(false);
+ readonly institutionOptions = signal([]);
+ private readonly selectedInstitutionsMap = signal(
+ new Map(),
+ );
+
+ queryParamMap = toSignal(this.route.queryParamMap, {
+ initialValue: this.route.snapshot.queryParamMap,
});
- readonly defaultWeights: WeightMap = {
- param1: 0.33,
- param2: 0.33,
- param3: 0.34,
- };
- readonly weightOptions: WeightSliderOption[] = [
+
+ selectedYearsQueryParams = computed(() =>
+ this.queryParamMap().getAll(this.yearParamKey).map(Number),
+ );
+ selectedTypesQueryParams = computed(() =>
+ this.queryParamMap().getAll(this.typeParamKey),
+ );
+ selectedLanguagesQueryParams = computed(() =>
+ this.queryParamMap().getAll(this.languageParamKey),
+ );
+ selectedInstitutionIdsQueryParams = computed(() =>
+ this.queryParamMap().getAll(this.institutionParamKey),
+ );
+ fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true');
+
+ // --- Reactive filtering of the in-panel search boxes, memoized as
+ // computed signals instead of being re-run as plain methods on every
+ // change-detection pass. ---
+ private readonly yearSearchTerm = toSignal(
+ this.yearSearchControl.valueChanges,
+ { initialValue: '' },
+ );
+ private readonly typeSearchTerm = toSignal(
+ this.typeSearchControl.valueChanges,
+ { initialValue: '' },
+ );
+ private readonly languageSearchTerm = toSignal(
+ this.languageSearchControl.valueChanges,
+ { initialValue: '' },
+ );
+
+ readonly filteredYearOptions = computed(() => {
+ const term = this.yearSearchTerm().trim();
+ if (!term) return this.publicationYearOptions;
+ return this.publicationYearOptions.filter((year) =>
+ String(year).includes(term),
+ );
+ });
+
+ readonly filteredTypeOptions = computed(() => {
+ const term = this.typeSearchTerm().trim().toLowerCase();
+ if (!term) return this.typeOptions;
+ return this.typeOptions.filter((type) =>
+ type.label.toLowerCase().includes(term),
+ );
+ });
+
+ readonly filteredLanguageOptions = computed(() => {
+ const term = this.languageSearchTerm().trim().toLowerCase();
+ if (!term) return this.languageOptions;
+ return this.languageOptions.filter((language) =>
+ language.label.toLowerCase().includes(term),
+ );
+ });
+
+ // Memoized instead of being rebuilt with a `flatMap` over every work on
+ // every single chip render inside the "topics" valueFormatter below.
+ private readonly worksTopicsById = computed(() => {
+ const map = new Map<
+ string,
+ { id?: string | null; display_name?: string | null }
+ >();
+ for (const work of this.works().elements ?? []) {
+ for (const topic of work.topics ?? []) {
+ if (topic.id) map.set(topic.id, topic);
+ }
+ }
+ return map;
+ });
+
+ readonly observers: FilterObserver[] = [
{
- key: 'param1',
- label: 'Parameter 1',
- icon: 'workspace_premium',
- description: 'Gewichtet Parameter 1.',
- defaultValue: 0.5,
- queryParamName: 'wParam1',
+ id: 'types',
+ queryParamKey: this.typeParamKey,
+ icon: 'category',
+ valueFormatter: (value: string) => translateWorkType(value) || value,
},
{
- key: 'param2',
- label: 'Parameter 2',
- icon: 'workspace_premium',
- description: 'Gewichtet Parameter 2.',
- defaultValue: 0.5,
- queryParamName: 'wParam2',
+ id: 'years',
+ queryParamKey: this.yearParamKey,
+ icon: 'calendar_today',
},
{
- key: 'param3',
- label: 'Parameter 3',
- icon: 'workspace_premium',
- description: 'Gewichtet Parameter 3.',
- defaultValue: 0.5,
- queryParamName: 'wParam3',
+ id: 'languages',
+ queryParamKey: this.languageParamKey,
+ icon: 'translate',
+ valueFormatter: (value: string) => translateLanguageCode(value) || value,
+ },
+ {
+ id: 'institutions',
+ queryParamKey: this.institutionParamKey,
+ icon: 'apartment',
+ valueFormatter: (value: string) =>
+ this.selectedInstitutionsMap().get(value)?.display_name ?? value,
+ },
+ {
+ id: 'topics',
+ queryParamKey: this.topicParamKey,
+ icon: 'topic',
+ valueFormatter: (value: string) => {
+ const stateTopic = this.state.topics().find((t) => t.id === value);
+ if (stateTopic) return stateTopic.display_name ?? value;
+ return this.worksTopicsById().get(value)?.display_name ?? value;
+ },
},
];
- readonly currentWeights = signal({
- raw: this.defaultWeights,
- normalized: { param1: 0.33, param2: 0.33, param3: 0.34 },
- rawSum: 2.5,
- normalizedSum: 1,
- valid: true,
- });
- fuzzySearch = signal(false);
+
+ // --- Data loading ---
+ // Driven declaratively off route.queryParamMap via switchMap, instead of
+ // a manual subscribe-per-change. This fixes two real bugs from the
+ // original version:
+ // 1. `loading` could get stuck `true` forever, because it was only ever
+ // reset from the `complete` callback — which RxJS never calls after
+ // an `error`.
+ // 2. Rapid filter changes opened a new subscription without cancelling
+ // the previous in-flight request, so a slower response for an older
+ // filter combination could arrive after a newer one and silently
+ // overwrite the correct results. `switchMap` cancels the stale
+ // request automatically.
+ readonly works = toSignal(
+ this.route.queryParamMap.pipe(
+ switchMap((params) => this.fetchWorks(params)),
+ takeUntilDestroyed(this.destroyRef),
+ ),
+ { initialValue: EMPTY_WORK_PAGE },
+ );
+
totalElements = computed(() => this.works()?.total ?? 0);
elements = computed(() => this.works()?.elements ?? []);
- workColumns: GenericColumn[] = [];
- titleTmp = viewChild.required>('titleTmp');
- typeTmp = viewChild.required>('typeTmp');
- yearTmp = viewChild.required>('yearTmp');
- languageTmp = viewChild.required>('languageTmp');
- institutionsTmp = viewChild.required>('institutionsTmp');
- topicsTmp = viewChild.required>('topicsTmp');
- citationsTmp = viewChild.required>('citationsTmp');
- actionsTmp = viewChild.required>('actionsTmp');
constructor() {
- this.route.queryParamMap
- .pipe(takeUntilDestroyed(this.destroyRef))
- .subscribe(() => {
- const fuzzy = this.route.snapshot.queryParamMap.get('fuzzy') === 'true';
- this.fuzzySearch.set(fuzzy);
- console.log('Query params changed, reloading works with fuzzy=', fuzzy);
- this.loadWorks();
- });
+ // Best-effort hydration of institution display names for institution
+ // IDs that arrived via the URL (shared link, page refresh, back
+ // button) rather than through the autocomplete — those never populate
+ // `selectedInstitutionsMap`, so the filter chip falls back to showing
+ // the raw ID. Wire this up to whatever "get institutions by id"
+ // endpoint your generated API client exposes.
+ effect(
+ () => {
+ const ids = this.selectedInstitutionIdsQueryParams();
+ const known = this.selectedInstitutionsMap();
+ const unresolved = ids.filter((id) => !known.has(id));
+ if (unresolved.length === 0) return;
+
+ // TODO: replace with your actual by-id institution lookup, e.g.:
+ // this.institutionsService.getInstitutionsByIds(unresolved).subscribe((results) => {
+ // this.selectedInstitutionsMap.update((map) => {
+ // const next = new Map(map);
+ // for (const inst of results) {
+ // if (inst.id) next.set(inst.id, inst);
+ // }
+ // return next;
+ // });
+ // });
+ },
+ { allowSignalWrites: true },
+ );
}
+
ngOnInit(): void {
- this.loadWorks();
- }
- ngAfterViewInit(): void {
- this.workColumns = [
- {
- id: 'title',
- header: 'Titel',
- type: 'accessor',
- accessorKey: 'title',
- },
- {
- id: 'type',
- header: 'Typ',
- type: 'accessor',
- accessorKey: 'type',
- },
- {
- id: 'publication_year',
- header: 'Jahr',
- type: 'accessor',
- accessorKey: 'publication_year',
- },
- {
- id: 'language',
- header: 'Sprache',
- type: 'display',
- },
- {
- id: 'institutions',
- header: 'Institutionen',
- type: 'display',
- },
- {
- id: 'topics',
- header: 'Themen',
- type: 'display',
- },
- {
- id: 'cited_by_count',
- header: 'Zitiert von',
- type: 'accessor',
- accessorKey: 'cited_by_count',
- },
- {
- id: 'actions',
- header: 'Aktionen',
- type: 'display',
- },
- ];
+ this.setupInstitutionAutocomplete();
}
- private loadWorks(): void {
- const payload = this.state.payload();
-
- console.log('GOT PAYLOAD', payload);
-
- const topicIds = this.state
+ private fetchWorks(params: ParamMap) {
+ this.loading.set(true);
+ // Base search topics — derived from the keyword→topic mapping.
+ // This remains the actual search criterion.
+ const baseTopicIds = this.state
.selectedKeywordEntries()
.map((entry) => entry.topic_mapping?.topic?.id)
.filter((id): id is string => !!id);
- console.log('GOT TOPIC IDS', topicIds);
+ const keywords = this.state.keywords();
- if (topicIds.length === 0) {
- console.warn('No topic IDs available');
- return;
+ if (baseTopicIds.length === 0 && keywords.length === 0) {
+ this.loading.set(false);
+ return of(EMPTY_WORK_PAGE);
}
- const keywords = payload?.keywords ?? [];
-
- const page = Number(this.route.snapshot.queryParamMap.get('page')) || 1;
-
- const size = Number(this.route.snapshot.queryParamMap.get('size')) || 10;
-
- const publicationYears = this.route.snapshot.queryParamMap
- .getAll('publicationYear')
+ const filterTopicIds = params.getAll(this.topicParamKey);
+ const page = Number(params.get(this.pageParamKey)) || 0;
+ const size = Number(params.get('size')) || 10;
+ const publicationYears = params
+ .getAll(this.yearParamKey)
.map(Number)
.filter((year) => !Number.isNaN(year));
+ const publicationTypes = params.getAll(this.typeParamKey);
+ const publicationLanguages = params.getAll(this.languageParamKey);
+ const institutionIds = params.getAll(this.institutionParamKey);
+ const fuzzy = params.get('fuzzy') === 'true';
+ const sortBy = (params.get('sort_by') ?? 'publication_year') as WorkSortBy;
+ const sortDirection = (params.get('sort_direction') ??
+ 'desc') as SortDirection;
- const publicationTypes =
- this.route.snapshot.queryParamMap.getAll('publicationType');
-
- const institutionIds = this.route.snapshot.queryParamMap.getAll(
- 'publicationInstitutionId',
- );
-
- const sortBy = (this.route.snapshot.queryParamMap.get('sort_by') ??
- 'publication_year') as WorkSortBy;
-
- const sortDirection = (this.route.snapshot.queryParamMap.get(
- 'sort_direction',
- ) ?? 'desc') as SortDirection;
-
- this.worksService
+ // ✅ Argument order matches the regenerated client exactly:
+ // topics, topicIds, filterTopicIds, keywords, fuzzy,
+ // publicationYear, publicationType, institutionIds, language,
+ // page, size, sortBy, sortOrder
+ return this.worksService
.getWorksByKeywords(
[],
- topicIds,
+ baseTopicIds,
+ filterTopicIds,
keywords,
- this.fuzzySearch(),
+ fuzzy,
publicationYears,
publicationTypes,
institutionIds,
- [],
+ publicationLanguages,
page,
size,
sortBy,
sortDirection,
)
- .pipe(takeUntilDestroyed(this.destroyRef))
- .subscribe({
- next: (page) => {
- console.log('GOT WORKS PAGE', page);
- this.works.set(page);
- },
- error: (err) => console.error(err),
+ .pipe(
+ catchError((err) => {
+ console.error(err);
+ return of(EMPTY_WORK_PAGE);
+ }),
+ finalize(() => this.loading.set(false)),
+ );
+ }
+
+ // ---------------- Filter handlers ----------------
+
+ private updateQueryParams(paramKey: string, value: unknown): void {
+ this.router.navigate([], {
+ queryParams: {
+ [paramKey]: value,
+ [this.pageParamKey]: 0,
+ },
+ queryParamsHandling: 'merge',
+ });
+ }
+
+ handleYearSelectionChange(event: MatSelectChange): void {
+ this.updateQueryParams(this.yearParamKey, event.value);
+ }
+
+ handleTypeSelectionChange(event: MatSelectChange): void {
+ this.updateQueryParams(this.typeParamKey, event.value);
+ }
+
+ handleLanguageSelectionChange(event: MatSelectChange): void {
+ this.updateQueryParams(this.languageParamKey, event.value);
+ }
+
+ displayInstitution(option: string | InstitutionAutocompleteOption): string {
+ return typeof option === 'string' ? option : (option.display_name ?? '');
+ }
+
+ selectInstitution(event: MatAutocompleteSelectedEvent): void {
+ const institution = event.option.value as InstitutionAutocompleteOption;
+ if (!institution.id) return;
+
+ this.selectedInstitutionsMap.update((map) => {
+ const next = new Map(map);
+ next.set(institution.id!, institution);
+ return next;
+ });
+
+ const current = this.selectedInstitutionIdsQueryParams();
+ if (!current.includes(institution.id)) {
+ this.updateQueryParams(this.institutionParamKey, [
+ ...current,
+ institution.id,
+ ]);
+ }
+ this.institutionSearchControl.setValue('');
+ }
+
+ clearFilters(): void {
+ this.router.navigate([], {
+ queryParams: {
+ keywords: this.state.keywordsList().join(','),
+ topicId: this.state.topicIds(),
+ fuzzy: this.state.fuzzySearch(),
+ page: 0,
+ size: 10,
+ sort_by: 'publication_year',
+ sort_direction: 'desc',
+ },
+ });
+ }
+
+ yearSelectionSummary(): string {
+ return this.summarizeSelection(this.selectedYearsQueryParams().map(String));
+ }
+
+ typeSelectionSummary(): string {
+ return this.summarizeSelection(this.selectedTypesQueryParams());
+ }
+
+ languageSelectionSummary(): string {
+ return this.summarizeSelection(
+ this.selectedLanguagesQueryParams().map(String),
+ );
+ }
+
+ private summarizeSelection(labels: string[]): string {
+ if (labels.length === 0) return '';
+ if (labels.length === 1) return labels[0];
+ return `+${labels.length}`;
+ }
+
+ focusSelectSearch(input: HTMLInputElement): void {
+ setTimeout(() => input.focus());
+ }
+
+ private setupInstitutionAutocomplete(): void {
+ this.institutionSearchControl.valueChanges
+ .pipe(
+ debounceTime(250),
+ map((value) => (typeof value === 'string' ? value.trim() : '')),
+ distinctUntilChanged(),
+ switchMap((query) => {
+ if (query.length < 2) {
+ this.institutionOptions.set([]);
+ return of([]);
+ }
+ this.institutionLookupLoading.set(true);
+ return this.institutionsService
+ .autocompleteInstitutions(query, undefined, undefined, 10)
+ .pipe(
+ map(
+ (response) =>
+ (response?.results ?? []) as InstitutionAutocompleteOption[],
+ ),
+ catchError(() => of([])),
+ finalize(() => {
+ this.institutionLookupLoading.set(false);
+ }),
+ );
+ }),
+ takeUntilDestroyed(this.destroyRef),
+ )
+ .subscribe((options) => {
+ const selectedIds = new Set(this.selectedInstitutionIdsQueryParams());
+ this.institutionOptions.set(
+ options.filter(
+ (option) => !!option.id && !selectedIds.has(option.id),
+ ),
+ );
});
}
- onWeightsChange(value: WeightsSlidersValue): void {
- this.currentWeights.set(value);
- } // fires once with the query-param-aware initial state — use it to load
- onApplyWeights(value: WeightsSlidersValue): void {
- this.currentWeights.set(value);
- this.loadWorks();
- } // reload works with the new weights applied
+
+ private createPublicationYearOptions(): number[] {
+ const currentYear = new Date().getFullYear();
+ return Array.from({ length: 90 }, (_, index) => currentYear - index);
+ }
}