Truncation, mouseover and populate filter button in person-list
This commit is contained in:
@@ -18,10 +18,11 @@
|
||||
</div>
|
||||
<h2 class="person-name">{{ person.display_name }}</h2>
|
||||
<p class="institution">
|
||||
<span>{{ institution(person)?.display_name }}</span>
|
||||
<span>{{ (institution(person)?.display_name ?? '') | truncate: 30 }}</span>
|
||||
@if (institution(person)?.country_code) {
|
||||
<img alt="" class="flag-img"
|
||||
[src]="`https://flagcdn.io/${institution(person)?.country_code?.toLowerCase()}.svg`" height="15">
|
||||
{{institution(person)?.country_code?.toUpperCase()}}
|
||||
}
|
||||
</p>
|
||||
<p class="person-id">{{ getDistinguishingId(person) }}</p>
|
||||
@@ -33,9 +34,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;">business</mat-icon>
|
||||
<span style="vertical-align: middle;">{{ (inst.display_name ?? '') | truncate: 30 }}</span>
|
||||
@if (inst.country_code) {
|
||||
<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 class="topic-tag" (click)="topicClick.emit(topic); $event.stopPropagation()">{{ topic }}</span>
|
||||
@for (topic of topics(person); track topic.id) {
|
||||
<span class="topic-tag" (click)="topicClick.emit(topic.display_name || ''); $event.stopPropagation()"
|
||||
[title]="getTopicTooltip(topic)">{{ topic.display_name }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,4 +75,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';
|
||||
|
||||
@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<CustomAuthor>();
|
||||
@Output() topicClick = new EventEmitter<string>();
|
||||
@Output() institutionClick = new EventEmitter<string>();
|
||||
|
||||
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) {
|
||||
|
||||
@@ -77,7 +77,8 @@
|
||||
[person]="person"
|
||||
[isBookmarked]="isBookmarked(person)"
|
||||
(bookmarkToggle)="toggleBookmark($event)"
|
||||
(topicClick)="onCardTopicClick($event)">
|
||||
(topicClick)="onCardTopicClick($event)"
|
||||
(institutionClick)="onCardInstitutionClick($event)">
|
||||
</app-person-card>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -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',
|
||||
@@ -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',
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -339,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user