diff --git a/webapp/src/app/modules/person-card/person-card.component.html b/webapp/src/app/modules/person-card/person-card.component.html index 9d07452e..31fd3885 100644 --- a/webapp/src/app/modules/person-card/person-card.component.html +++ b/webapp/src/app/modules/person-card/person-card.component.html @@ -17,13 +17,6 @@

{{ person.display_name }}

-

- {{ institution(person)?.display_name }} - @if (institution(person)?.country_code) { - - } -

{{ getDistinguishingId(person) }}

Publikationen: {{ person.works_count }} · @@ -33,9 +26,27 @@

+ @if (institution(person); as inst) { +
+ + business + {{ (inst.display_name ?? '') | truncate: 30 }} + @if (inst.country_code) { + + {{ inst.country_code.toUpperCase() + }} + } + +
+ } +
- @for (topic of topics(person); track topic) { - {{ topic }} + @for (topic of topics(person); track topic.id) { + {{ topic.display_name }} }
@@ -56,4 +67,4 @@ - + \ No newline at end of file diff --git a/webapp/src/app/modules/person-card/person-card.component.scss b/webapp/src/app/modules/person-card/person-card.component.scss index 520008c2..cb82fcb0 100644 --- a/webapp/src/app/modules/person-card/person-card.component.scss +++ b/webapp/src/app/modules/person-card/person-card.component.scss @@ -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; diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index 89ebf0e8..26c3cc4c 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -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'; @Component({ selector: 'app-person-card', standalone: true, - imports: [CommonModule, RouterLink, MatIconModule], + imports: [CommonModule, RouterLink, MatIconModule, TruncatePipe], templateUrl: './person-card.component.html', styleUrl: './person-card.component.scss', }) @@ -16,6 +17,7 @@ export class PersonCardComponent { @Input() isBookmarked = false; @Output() bookmarkToggle = new EventEmitter(); @Output() topicClick = new EventEmitter(); + @Output() institutionClick = new EventEmitter(); getInitials(name: string | null | undefined): string { if (!name) return 'U'; @@ -41,13 +43,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) { diff --git a/webapp/src/app/modules/person-list/person-list.component.html b/webapp/src/app/modules/person-list/person-list.component.html index f516e3d9..345994e1 100644 --- a/webapp/src/app/modules/person-list/person-list.component.html +++ b/webapp/src/app/modules/person-list/person-list.component.html @@ -77,7 +77,8 @@ [person]="person" [isBookmarked]="isBookmarked(person)" (bookmarkToggle)="toggleBookmark($event)" - (topicClick)="onCardTopicClick($event)"> + (topicClick)="onCardTopicClick($event)" + (institutionClick)="onCardInstitutionClick($event)"> } @@ -89,28 +90,15 @@ } - - @if (totalPages > 1) { -
- - -
- @for (p of pageList; track p) { - - } -
- - -
- } + + + diff --git a/webapp/src/app/modules/person-list/person-list.component.scss b/webapp/src/app/modules/person-list/person-list.component.scss index d8f2eb02..9fcee184 100644 --- a/webapp/src/app/modules/person-list/person-list.component.scss +++ b/webapp/src/app/modules/person-list/person-list.component.scss @@ -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 { diff --git a/webapp/src/app/modules/person-list/person-list.component.ts b/webapp/src/app/modules/person-list/person-list.component.ts index 487caa53..fef6aab5 100644 --- a/webapp/src/app/modules/person-list/person-list.component.ts +++ b/webapp/src/app/modules/person-list/person-list.component.ts @@ -5,7 +5,7 @@ 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'; @@ -21,6 +21,7 @@ import { SharedStateService } from '../../shared/services/shared-state.service'; import { PaginationService } from '../../shared/services/pagination.service'; import { finalize } from 'rxjs'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { createLoadError } from '../../shared/utils/errorHandler'; @Component({ selector: 'app-person-list', @@ -65,7 +66,7 @@ export class PersonListComponent { selectedTopics = new Set(); // 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 }); @@ -187,9 +188,21 @@ export class PersonListComponent { this.persons = (response.results ?? []) as CustomAuthor[]; this.total = response.meta?.count ?? 0; }, - error: (err) => { - console.error('Error loading persons:', err); - }, + error: createLoadError( + this.snackBar, + () => + this.load( + query, + page, + pageSize, + topics, + institutionName, + yearFilterEnabled, + filterMode, + filterYear, + ), + 'Beim Laden der Personen ist ein Fehler aufgetreten', + ), }); } @@ -233,7 +246,7 @@ 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}`; @@ -300,53 +313,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', }); } @@ -379,6 +352,11 @@ export class PersonListComponent { this.topicSearchControl.setValue(topic); } + onCardInstitutionClick(institutionName: string): void { + this.institutionControl.setValue(institutionName); + this.applySidebarFilters(); + } + isBookmarked(person: CustomAuthor): boolean { return !!person.id && this.bookmarkedIds.has(person.id); }