publications/persons: add open-institution shortcut to institution tags and filter chips
This commit is contained in:
@@ -95,6 +95,14 @@
|
||||
>{{ inst.country_code.toUpperCase() }}</span
|
||||
>
|
||||
}
|
||||
@if (institutionPageId() && !loading()) {
|
||||
<mat-icon
|
||||
class="institution-open-icon"
|
||||
(click)="openInstitutionPage($event)"
|
||||
aria-label="Institutionsseite öffnen"
|
||||
>open_in_new</mat-icon
|
||||
>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -162,6 +162,31 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.institution-open-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .institution-open-icon {
|
||||
opacity: 0.7;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--sg-primary);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, input, computed, output } from '@angular/core';
|
||||
import { Component, inject, input, computed, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
|
||||
@@ -23,6 +23,8 @@ import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
styleUrl: './person-card.component.scss',
|
||||
})
|
||||
export class PersonCardComponent {
|
||||
private readonly router = inject(Router);
|
||||
|
||||
person = input.required<CustomAuthor>();
|
||||
isBookmarked = input<boolean>(false);
|
||||
loading = input<boolean>(false);
|
||||
@@ -66,6 +68,20 @@ export class PersonCardComponent {
|
||||
return newestInstitution;
|
||||
});
|
||||
|
||||
institutionPageId = computed<string | null>(
|
||||
() => this.institution()?.id?.split('/').pop() ?? null,
|
||||
);
|
||||
|
||||
openInstitutionPage(event: Event): void {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
const id = this.institutionPageId();
|
||||
if (!id) return;
|
||||
|
||||
void this.router.navigate(['/institution', id]);
|
||||
}
|
||||
|
||||
isInstitutionActive = computed<boolean>(() => {
|
||||
const active = this.activeInstitutionName().trim().toLowerCase();
|
||||
if (!active) return false;
|
||||
|
||||
@@ -82,6 +82,14 @@
|
||||
filter.countryCode.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
@if (findInstitutionPageIdByName(filter.value)) {
|
||||
<mat-icon
|
||||
class="institution-open-icon"
|
||||
(click)="openInstitutionPage(filter.value, $event)"
|
||||
aria-label="Institutionsseite öffnen"
|
||||
>open_in_new</mat-icon
|
||||
>
|
||||
}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -217,6 +217,27 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-institution-chip:hover .institution-open-icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.filter-chip button,
|
||||
.active-topic-filter button,
|
||||
.active-institution-filter button,
|
||||
|
||||
@@ -328,6 +328,41 @@ export class PersonListComponent {
|
||||
return filter.label.replace(/^Institution:\s*/, '');
|
||||
}
|
||||
|
||||
findInstitutionPageIdByName(institutionName: string): string | null {
|
||||
const normalized = institutionName.trim().toLowerCase();
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const person of this.persons) {
|
||||
const candidates: Array<DehydratedInstitution | undefined> = [
|
||||
...(person.last_known_institutions ?? []),
|
||||
...(person.affiliations ?? []).map((a) => a.institution ?? undefined),
|
||||
];
|
||||
|
||||
for (const inst of candidates) {
|
||||
if (
|
||||
inst?.id &&
|
||||
(inst.display_name ?? '').trim().toLowerCase() === normalized
|
||||
) {
|
||||
return inst.id.split('/').pop() ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
openInstitutionPage(institutionName: string, event: Event): void {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
const id = this.findInstitutionPageIdByName(institutionName);
|
||||
if (!id) return;
|
||||
|
||||
void this.router.navigate(['/institution', id]);
|
||||
}
|
||||
|
||||
private findInstitutionCountryCode(institutionName: string): string | null {
|
||||
const normalized = institutionName.trim().toLowerCase();
|
||||
if (!normalized) {
|
||||
|
||||
@@ -275,6 +275,12 @@
|
||||
instCountry.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
<mat-icon
|
||||
class="institution-open-icon"
|
||||
(click)="openInstitutionPage(institution.id, $event)"
|
||||
aria-label="Institutionsseite öffnen"
|
||||
>open_in_new</mat-icon
|
||||
>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
@@ -412,6 +418,12 @@
|
||||
institution.country.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
<mat-icon
|
||||
class="institution-open-icon"
|
||||
(click)="openInstitutionPage(institution.id, $event)"
|
||||
aria-label="Institutionsseite öffnen"
|
||||
>open_in_new</mat-icon
|
||||
>
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
|
||||
@@ -301,6 +301,29 @@ h2 {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon,
|
||||
.publication-institution-tag .institution-open-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-institution-chip:hover .institution-open-icon,
|
||||
.publication-institution-tag:hover .institution-open-icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon:hover,
|
||||
.publication-institution-tag .institution-open-icon:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.filter-meta-chip__label,
|
||||
.filter-topic-chip__label {
|
||||
overflow: hidden;
|
||||
|
||||
@@ -486,6 +486,19 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
openInstitutionPage(
|
||||
institutionId: string | null | undefined,
|
||||
event: Event,
|
||||
): void {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
const id = institutionId?.split('/').pop();
|
||||
if (!id) return;
|
||||
|
||||
void this.router.navigate(['/institution', id]);
|
||||
}
|
||||
|
||||
getSelectedTopicTooltip(topic: TopicAutocompleteOption): string {
|
||||
const workTopic = this.findPublicationTopic(topic.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user