Merge branch 'dev' of https://project.nes.uni-due.de/gitea/lbs/smartguide into ts-82-author-overview-and-description
This commit is contained in:
@@ -17,13 +17,6 @@
|
||||
</button>
|
||||
</div>
|
||||
<h2 [skText]="loading" class="person-name">{{ person.display_name }}</h2>
|
||||
<p class="institution">
|
||||
<span [skText]="loading">{{ institution(person)?.display_name }}</span>
|
||||
@if (institution(person)?.country_code && !loading) {
|
||||
<img alt="" class="flag-img"
|
||||
[src]="`https://flagcdn.io/${institution(person)?.country_code?.toLowerCase()}.svg`" height="15">
|
||||
}
|
||||
</p>
|
||||
<p [skText]="loading" class="person-id">{{ getDistinguishingId(person) }}</p>
|
||||
<p [skText]="loading" class="stats">
|
||||
Publikationen: {{ person.works_count }} ·
|
||||
@@ -33,9 +26,27 @@
|
||||
</a>
|
||||
|
||||
<div class="card-body">
|
||||
@if (institution(person); as inst) {
|
||||
<div class="institution-row" style="margin-bottom: 8px;">
|
||||
<span class="institution-tag" (click)="institutionClick.emit(inst.display_name || ''); $event.stopPropagation()"
|
||||
[title]="inst.display_name || ''">
|
||||
<mat-icon
|
||||
style="font-size: 12px; width: 12px; height: 12px; margin-right: 4px; vertical-align: middle;">apartment</mat-icon>
|
||||
<span [skText]="loading" style="vertical-align: middle;">{{ (inst.display_name ?? '') | truncate: 30 }}</span>
|
||||
@if (inst.country_code && !loading) {
|
||||
<img alt="" class="flag-img" [src]="`https://flagcdn.io/${inst.country_code.toLowerCase()}.svg`" height="10"
|
||||
style="margin-left: 6px; vertical-align: middle;">
|
||||
<span style="font-size: 9px; margin-left: 2px; vertical-align: middle;">{{ inst.country_code.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="topic-row">
|
||||
@for (topic of topics(person); track topic) {
|
||||
<span [skText]="loading" class="topic-tag" (click)="topicClick.emit(topic); $event.stopPropagation()">{{ topic }}</span>
|
||||
@for (topic of topics(person); track topic.id) {
|
||||
<span [skText]="loading" class="topic-tag" (click)="topicClick.emit(topic.display_name || ''); $event.stopPropagation()"
|
||||
[title]="getTopicTooltip(topic)">{{ topic.display_name }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,4 +67,4 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</article>
|
||||
@@ -107,11 +107,10 @@
|
||||
font-weight: 600;
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.institution {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
@@ -120,6 +119,26 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.institution-tag {
|
||||
background: var(--sg-primary-soft);
|
||||
border: 1px solid var(--sg-primary-border, var(--sg-border));
|
||||
color: var(--sg-primary);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
border-color: var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.flag-img {
|
||||
border: 1px solid;
|
||||
vertical-align: -10px;
|
||||
|
||||
@@ -2,12 +2,13 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { CustomAuthor, DehydratedInstitution } from '../../api';
|
||||
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
|
||||
import { TruncatePipe } from '../../shared/pipes/truncate.pipe';
|
||||
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
|
||||
@Component({
|
||||
selector: 'app-person-card',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink, MatIconModule,SkTextDirective],
|
||||
imports: [CommonModule, RouterLink, MatIconModule, TruncatePipe,SkTextDirective],
|
||||
templateUrl: './person-card.component.html',
|
||||
styleUrl: './person-card.component.scss',
|
||||
})
|
||||
@@ -17,6 +18,7 @@ export class PersonCardComponent {
|
||||
@Input() loading = false;
|
||||
@Output() bookmarkToggle = new EventEmitter<CustomAuthor>();
|
||||
@Output() topicClick = new EventEmitter<string>();
|
||||
@Output() institutionClick = new EventEmitter<string>();
|
||||
|
||||
getInitials(name: string | null | undefined): string {
|
||||
if (!name) return 'U';
|
||||
@@ -42,13 +44,22 @@ export class PersonCardComponent {
|
||||
);
|
||||
}
|
||||
|
||||
topics(person: CustomAuthor): string[] {
|
||||
topics(person: CustomAuthor): WorkTopic[] {
|
||||
return (person.topics ?? [])
|
||||
.map((t) => t.display_name)
|
||||
.filter((name): name is string => !!name)
|
||||
.filter((t): t is WorkTopic => !!t.display_name)
|
||||
.slice(0, 3);
|
||||
}
|
||||
|
||||
getTopicTooltip(topic: WorkTopic): string {
|
||||
const parts: string[] = [];
|
||||
if (topic.domain?.display_name) parts.push(topic.domain.display_name);
|
||||
if (topic.field?.display_name) parts.push(topic.field.display_name);
|
||||
if (topic.subfield?.display_name) parts.push(topic.subfield.display_name);
|
||||
|
||||
if (parts.length === 0) return topic.display_name || '';
|
||||
return parts.join(' - ');
|
||||
}
|
||||
|
||||
getDistinguishingId(person: CustomAuthor): string {
|
||||
if (!person) return '';
|
||||
if (person.orcid) {
|
||||
|
||||
@@ -62,19 +62,16 @@
|
||||
|
||||
<section class="results-panel">
|
||||
<div class="results-head">
|
||||
<strong [skText]="loading">{{ total | number: "1.0-0" }} Personen gefunden</strong>
|
||||
<span>Sortiert nach Publikationen und Zitierungen</span>
|
||||
<strong [skText]="loading" >{{ total | number: "1.0-0" }} Personen gefunden</strong>
|
||||
<!--><span>Sortiert nach Publikationen und Zitierungen</span>-->
|
||||
</div>
|
||||
|
||||
@if (sortedPersons.length) {
|
||||
<div class="person-grid">
|
||||
@for (person of sortedPersons; track person.id) {
|
||||
<app-person-card
|
||||
[loading]="loading"
|
||||
[person]="person"
|
||||
[isBookmarked]="isBookmarked(person)"
|
||||
(bookmarkToggle)="toggleBookmark($event)"
|
||||
(topicClick)="onCardTopicClick($event)">
|
||||
<app-person-card [loading]="loading" [person]="person" [isBookmarked]="isBookmarked(person)"
|
||||
(bookmarkToggle)="toggleBookmark($event)" (topicClick)="onCardTopicClick($event)"
|
||||
(institutionClick)="onCardInstitutionClick($event)">
|
||||
</app-person-card>
|
||||
}
|
||||
</div>
|
||||
@@ -86,28 +83,11 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Custom Pagination Controls -->
|
||||
@if (totalPages > 1) {
|
||||
<div class="custom-pagination">
|
||||
<button class="paginator-btn" [disabled]="isFirstPage()" (click)="prevPage()" aria-label="Vorherige Seite">
|
||||
<mat-icon>chevron_left</mat-icon>
|
||||
<span>Vorherige</span>
|
||||
</button>
|
||||
|
||||
<div class="page-numbers">
|
||||
@for (p of pageList; track p) {
|
||||
<button [skText]="loading" class="page-number-btn" [class.active]="p === currentPage" (click)="goToPage(p)">
|
||||
{{ p }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button class="paginator-btn" [disabled]="isLastPage()" (click)="nextPage()" aria-label="Nächste Seite">
|
||||
<span>Nächste</span>
|
||||
<mat-icon>chevron_right</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
<!-- Paginator -->
|
||||
<mat-paginator [length]="total" [pageSize]="paginationService.selection"
|
||||
[pageSizeOptions]="paginationService.options" [pageIndex]="currentPage - 1" (page)="onPageChange($event)"
|
||||
aria-label="Ausgewählte Seite">
|
||||
</mat-paginator>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@@ -141,11 +121,25 @@
|
||||
<div class="filter-section">
|
||||
<h3 class="filter-section-title">Institution</h3>
|
||||
<div class="topic-search-wrapper">
|
||||
<mat-icon>business</mat-icon>
|
||||
<input type="text" [formControl]="institutionControl" placeholder="Institution suchen..."
|
||||
(keyup.enter)="applySidebarFilters()" />
|
||||
<mat-icon>apartment</mat-icon>
|
||||
<input type="text" [formControl]="institutionControl" [matAutocomplete]="auto"
|
||||
placeholder="Institution suchen..." (keyup.enter)="applySidebarFilters()" />
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onInstitutionSelected($event)">
|
||||
@for (institution of institutionOptions(); track institution.id) {
|
||||
<mat-option [value]="institution.display_name">
|
||||
<span>{{ institution.display_name }}</span>
|
||||
@if (institution.hint) {
|
||||
<small>{{ institution.hint }}</small>
|
||||
}
|
||||
</mat-option>
|
||||
}
|
||||
@if (!institutionLookupLoading() && institutionOptions().length === 0 && institutionControl.value &&
|
||||
institutionControl.value.trim().length >= 2) {
|
||||
<mat-option disabled>Keine Institution gefunden</mat-option>
|
||||
}
|
||||
</mat-autocomplete>
|
||||
@if (institutionControl.value) {
|
||||
<button class="clear-topic-search" (click)="institutionControl.setValue(''); applySidebarFilters()">
|
||||
<button class="clear-topic-search" (click)="clearInstitutionFilter()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -198,70 +198,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding-top: 16px;
|
||||
}
|
||||
|
||||
.paginator-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 12px;
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
mat-paginator {
|
||||
background: transparent !important;
|
||||
border-top: 1px solid var(--sg-border);
|
||||
margin-top: 16px;
|
||||
color: var(--sg-text);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--sg-surface-soft);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.page-numbers {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.page-number-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: var(--sg-surface-soft);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.filters-sidebar {
|
||||
@@ -380,6 +321,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-option small {
|
||||
display: block;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.layout-container {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
@@ -12,13 +12,14 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
|
||||
import { CustomAuthor, DehydratedInstitution, PersonsService } from '../../api';
|
||||
import { CustomAuthor, DehydratedInstitution, PersonsService, InstitutionsService } from '../../api';
|
||||
import { TopicsService } from '../../api/api/topics.service';
|
||||
import { TopicHierarchyComponent } from '../topic-hierarchy/topic-hierarchy.component';
|
||||
import { PersonCardComponent } from '../person-card/person-card.component';
|
||||
import { SharedStateService } from '../../shared/services/shared-state.service';
|
||||
import { PaginationService } from '../../shared/services/pagination.service';
|
||||
import { finalize } from 'rxjs';
|
||||
import { finalize, debounceTime, distinctUntilChanged, switchMap, map, of, catchError } from 'rxjs';
|
||||
import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
|
||||
import {
|
||||
@@ -27,6 +28,8 @@ import {
|
||||
NavigationStart,
|
||||
NavigationCancel,
|
||||
} from '@angular/router';
|
||||
import { createLoadError } from '../../shared/utils/errorHandler';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-list',
|
||||
imports: [
|
||||
@@ -42,7 +45,8 @@ import {
|
||||
MatRadioModule,
|
||||
TopicHierarchyComponent,
|
||||
PersonCardComponent,
|
||||
SkTextDirective
|
||||
SkTextDirective,
|
||||
MatAutocompleteModule,
|
||||
],
|
||||
templateUrl: './person-list.component.html',
|
||||
styleUrl: './person-list.component.scss',
|
||||
@@ -52,6 +56,8 @@ export class PersonListComponent {
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly personsService = inject(PersonsService);
|
||||
private readonly topicsService = inject(TopicsService);
|
||||
private readonly institutionsService = inject(InstitutionsService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
public readonly state = inject(SharedStateService);
|
||||
public readonly paginationService = inject(PaginationService);
|
||||
@@ -62,12 +68,21 @@ export class PersonListComponent {
|
||||
persons: CustomAuthor[] = [];
|
||||
total = 0;
|
||||
currentPage = 1;
|
||||
readonly institutionOptions = signal<any[]>([]);
|
||||
readonly institutionLookupLoading = signal<boolean>(false);
|
||||
|
||||
// Selected filter states
|
||||
selectedTopics = new Set<string>();
|
||||
searchValue = signal<string | null>(null);
|
||||
|
||||
// Applied filter states (reflecting actual URL query params)
|
||||
appliedInstitutionName = '';
|
||||
appliedYearFilterEnabled = false;
|
||||
appliedFilterMode: 'in' | 'from' = 'from';
|
||||
appliedFilterYear = new Date().getFullYear() - 1;
|
||||
|
||||
// Forms
|
||||
sortControl = new FormControl('relevance', { nonNullable: true });
|
||||
sortControl = new FormControl('works', { nonNullable: true });
|
||||
topicSearchControl = new FormControl('', { nonNullable: true });
|
||||
institutionControl = new FormControl('', { nonNullable: true });
|
||||
yearFilterEnabledControl = new FormControl(false, { nonNullable: true });
|
||||
@@ -105,15 +120,13 @@ export class PersonListComponent {
|
||||
this.yearFilterEnabledControl.disable();
|
||||
}
|
||||
|
||||
this.setupInstitutionAutocomplete();
|
||||
// Enable/disable the year filter checkbox based on the presence of an institution value
|
||||
this.updateYearFilterState(this.institutionControl.value);
|
||||
this.institutionControl.valueChanges
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((val) => {
|
||||
if (!val) {
|
||||
this.yearFilterEnabledControl.disable();
|
||||
this.yearFilterEnabledControl.setValue(false);
|
||||
} else {
|
||||
this.yearFilterEnabledControl.enable();
|
||||
}
|
||||
this.updateYearFilterState(val);
|
||||
});
|
||||
|
||||
this.route.queryParams
|
||||
@@ -145,7 +158,8 @@ export class PersonListComponent {
|
||||
this.searchValue.set(query || null);
|
||||
}
|
||||
if (this.institutionControl.value !== institutionName) {
|
||||
this.institutionControl.setValue(institutionName);
|
||||
this.institutionControl.setValue(institutionName, { emitEvent: false });
|
||||
this.updateYearFilterState(institutionName);
|
||||
}
|
||||
if (this.yearFilterEnabledControl.value !== yearFilterEnabled) {
|
||||
this.yearFilterEnabledControl.setValue(yearFilterEnabled);
|
||||
@@ -156,6 +170,12 @@ export class PersonListComponent {
|
||||
if (this.filterYearControl.value !== filterYear) {
|
||||
this.filterYearControl.setValue(filterYear);
|
||||
}
|
||||
|
||||
// Update applied filter states
|
||||
this.appliedInstitutionName = institutionName;
|
||||
this.appliedYearFilterEnabled = yearFilterEnabled;
|
||||
this.appliedFilterMode = filterMode;
|
||||
this.appliedFilterYear = filterYear;
|
||||
});
|
||||
|
||||
// Use resolver value
|
||||
@@ -208,17 +228,17 @@ export class PersonListComponent {
|
||||
}> {
|
||||
const list: Array<{ category: string; value: string; label: string }> = [];
|
||||
this.selectedTopics.forEach((t) => {
|
||||
list.push({ category: 'topic', value: t, label: t });
|
||||
list.push({ category: 'topic', value: t, label: `Thema: ${t}` });
|
||||
});
|
||||
if (this.institutionControl.value) {
|
||||
let label = `Institution: ${this.institutionControl.value}`;
|
||||
if (this.yearFilterEnabledControl.value) {
|
||||
const modeLabel = this.filterModeControl.value === 'in' ? 'in' : 'from';
|
||||
label += ` (${modeLabel} ${this.filterYearControl.value})`;
|
||||
if (this.appliedInstitutionName) {
|
||||
let label = `Institution: ${this.appliedInstitutionName}`;
|
||||
if (this.appliedYearFilterEnabled) {
|
||||
const modeLabel = this.appliedFilterMode === 'in' ? 'in' : 'from';
|
||||
label += ` (${modeLabel} ${this.appliedFilterYear})`;
|
||||
}
|
||||
list.push({
|
||||
category: 'institutionName',
|
||||
value: this.institutionControl.value,
|
||||
value: this.appliedInstitutionName,
|
||||
label: label,
|
||||
});
|
||||
}
|
||||
@@ -229,7 +249,9 @@ export class PersonListComponent {
|
||||
if (filter.category === 'topic') {
|
||||
this.selectedTopics.delete(filter.value);
|
||||
} else if (filter.category === 'institutionName') {
|
||||
this.institutionControl.setValue('');
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
this.updateYearFilterState('');
|
||||
this.institutionOptions.set([]);
|
||||
this.yearFilterEnabledControl.setValue(false);
|
||||
this.filterModeControl.setValue('from');
|
||||
this.filterYearControl.setValue(new Date().getFullYear() - 1);
|
||||
@@ -239,7 +261,9 @@ export class PersonListComponent {
|
||||
|
||||
clearAllFilters(): void {
|
||||
this.selectedTopics.clear();
|
||||
this.institutionControl.setValue('');
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
this.updateYearFilterState('');
|
||||
this.institutionOptions.set([]);
|
||||
this.yearFilterEnabledControl.setValue(false);
|
||||
this.filterModeControl.setValue('from');
|
||||
this.filterYearControl.setValue(new Date().getFullYear() - 1);
|
||||
@@ -275,53 +299,13 @@ export class PersonListComponent {
|
||||
});
|
||||
}
|
||||
|
||||
// Pagination custom calculation
|
||||
get totalPages(): number {
|
||||
return Math.max(
|
||||
1,
|
||||
Math.ceil(this.total / this.paginationService.selection),
|
||||
);
|
||||
}
|
||||
|
||||
get pageList(): number[] {
|
||||
const list: number[] = [];
|
||||
const maxPagesToShow = 5;
|
||||
let start = Math.max(1, this.currentPage - 2);
|
||||
let end = Math.min(this.totalPages, start + maxPagesToShow - 1);
|
||||
|
||||
if (end - start + 1 < maxPagesToShow) {
|
||||
start = Math.max(1, end - maxPagesToShow + 1);
|
||||
}
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
list.push(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
isFirstPage(): boolean {
|
||||
return this.currentPage === 1;
|
||||
}
|
||||
|
||||
isLastPage(): boolean {
|
||||
return this.currentPage >= this.totalPages;
|
||||
}
|
||||
|
||||
prevPage(): void {
|
||||
if (!this.isFirstPage()) {
|
||||
this.goToPage(this.currentPage - 1);
|
||||
}
|
||||
}
|
||||
|
||||
nextPage(): void {
|
||||
if (!this.isLastPage()) {
|
||||
this.goToPage(this.currentPage + 1);
|
||||
}
|
||||
}
|
||||
|
||||
goToPage(p: number): void {
|
||||
onPageChange(event: PageEvent): void {
|
||||
this.paginationService.selection = event.pageSize;
|
||||
this.router.navigate([], {
|
||||
queryParams: { page: p },
|
||||
queryParams: {
|
||||
page: event.pageIndex + 1,
|
||||
pageSize: event.pageSize,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
@@ -354,6 +338,13 @@ export class PersonListComponent {
|
||||
this.topicSearchControl.setValue(topic);
|
||||
}
|
||||
|
||||
onCardInstitutionClick(institutionName: string): void {
|
||||
this.institutionControl.setValue(institutionName, { emitEvent: false });
|
||||
this.updateYearFilterState(institutionName);
|
||||
this.institutionOptions.set([]);
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
isBookmarked(person: CustomAuthor): boolean {
|
||||
return !!person.id && this.bookmarkedIds.has(person.id);
|
||||
}
|
||||
@@ -368,6 +359,61 @@ export class PersonListComponent {
|
||||
|
||||
|
||||
|
||||
private setupInstitutionAutocomplete(): void {
|
||||
this.institutionControl.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.searchInstitutions(query).pipe(
|
||||
catchError(() => of([])),
|
||||
finalize(() => {
|
||||
this.institutionLookupLoading.set(false);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((options) => {
|
||||
this.institutionOptions.set(options);
|
||||
});
|
||||
}
|
||||
|
||||
private searchInstitutions(query: string) {
|
||||
return this.institutionsService.autocompleteInstitutions(query, undefined, undefined, 10)
|
||||
.pipe(map((response) => response.results ?? []));
|
||||
}
|
||||
|
||||
updateYearFilterState(val: string): void {
|
||||
if (!val) {
|
||||
this.yearFilterEnabledControl.disable();
|
||||
this.yearFilterEnabledControl.setValue(false);
|
||||
} else {
|
||||
this.yearFilterEnabledControl.enable();
|
||||
}
|
||||
}
|
||||
|
||||
clearInstitutionFilter(): void {
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
this.updateYearFilterState('');
|
||||
this.institutionOptions.set([]);
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
onInstitutionSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
const val = event.option.value;
|
||||
this.institutionControl.setValue(val, { emitEvent: false });
|
||||
this.updateYearFilterState(val);
|
||||
this.institutionOptions.set([]);
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
private parseQueryParamArray(val: any): string[] {
|
||||
if (!val) return [];
|
||||
if (Array.isArray(val)) return val;
|
||||
|
||||
@@ -179,7 +179,7 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
private readonly httpClient: HttpClient,
|
||||
public readonly paginationService: PaginationService,
|
||||
private readonly snackBar: MatSnackBar,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.setupInstitutionAutocomplete();
|
||||
|
||||
Reference in New Issue
Block a user