feature/person-overview-wordcloud #288

Merged
kallweit merged 3 commits from feature/person-overview-wordcloud into dev 2026-08-17 14:18:48 +02:00
17 changed files with 462 additions and 9 deletions
@@ -45,6 +45,7 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
private componentRef: ComponentRef<T> | null = null;
private showTimeout?: ReturnType<typeof setTimeout>;
private hideTimeout?: ReturnType<typeof setTimeout>;
private dismissTimeout?: ReturnType<typeof setTimeout>;
private isOverHost = false;
private isOverOverlay = false;
@@ -84,6 +85,24 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
this.scheduleHide();
}
@HostListener('click')
onHostClick(): void {
this.scheduleDismiss();
}
private scheduleDismiss(): void {
clearTimeout(this.dismissTimeout);
this.dismissTimeout = setTimeout(() => this.dismiss());
}
private dismiss(): void {
clearTimeout(this.showTimeout);
clearTimeout(this.hideTimeout);
this.isOverHost = false;
this.isOverOverlay = false;
this.hide();
}
private scheduleHide(): void {
this.hideTimeout = setTimeout(() => {
if (!this.isOverHost && !this.isOverOverlay) {
@@ -155,6 +174,7 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
overlayElement.addEventListener('mouseenter', this.onOverlayEnter);
overlayElement.addEventListener('mouseleave', this.onOverlayLeave);
overlayElement.addEventListener('click', this.onOverlayClick, true);
}
private applyMaxWidth(
@@ -179,11 +199,16 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
this.scheduleHide();
};
private readonly onOverlayClick = (): void => {
this.scheduleDismiss();
};
private hide(): void {
if (this.overlayRef) {
const overlayElement = this.overlayRef.overlayElement;
overlayElement.removeEventListener('mouseenter', this.onOverlayEnter);
overlayElement.removeEventListener('mouseleave', this.onOverlayLeave);
overlayElement.removeEventListener('click', this.onOverlayClick, true);
this.overlayRef.detach();
}
this.componentRef = null;
@@ -192,6 +217,7 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
ngOnDestroy(): void {
clearTimeout(this.showTimeout);
clearTimeout(this.hideTimeout);
clearTimeout(this.dismissTimeout);
this.overlayRef?.dispose();
}
}
@@ -44,6 +44,9 @@
[color]="tag.color"
[disabled]="!tag.id"
[active]="isTagActive(tag)"
[secondaryActionLabel]="tagAction(tag)?.label ?? null"
[secondaryActionLink]="tagAction(tag)?.link ?? null"
[secondaryActionQueryParams]="tagAction(tag)?.queryParams ?? null"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="onTagClick(tag)">
@@ -14,6 +14,7 @@ import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { TopicCount } from '../../api';
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component';
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
@@ -45,6 +46,12 @@ interface InterestTag {
domainDescription: string;
}
interface InterestTagAction {
label: string;
link: unknown[];
queryParams: Record<string, string | number>;
}
const MAX_TAGS = 5;
@Component({
@@ -69,6 +76,10 @@ export class PersonInterestingComponent implements OnInit {
readonly topics = input<TopicCount[] | null>(null);
readonly loading = input<boolean>(false);
readonly personPublicationsLink = input<unknown[] | null>(null);
readonly personName = input<string>('');
readonly legendExpanded = signal(false);
readonly activeLegendFieldIds = signal<ReadonlySet<string>>(new Set());
readonly activeLegendSubfieldIds = signal<ReadonlySet<string>>(new Set());
@@ -142,6 +153,36 @@ export class PersonInterestingComponent implements OnInit {
});
}
private readonly tagActions = computed(() => {
const actions = new Map<string, InterestTagAction>();
const link = this.personPublicationsLink();
if (!link) {
return actions;
}
const person = this.personName() || 'dieser Person';
for (const tag of this.tags()) {
if (!tag.id) continue;
actions.set(tag.id, {
label: `Publikationen von ${person}`,
link,
queryParams: {
[workQueryParamKeys.page]: 0,
[workQueryParamKeys.topicId]: tag.id,
},
});
}
return actions;
});
tagAction(tag: InterestTag): InterestTagAction | null {
return this.tagActions().get(tag.id) ?? null;
}
onTagClick(tag: InterestTag): void {
if (!tag.id) return;
this.tagClick.emit({
@@ -171,8 +171,15 @@
type="button"
class="main-topic-button"
[disabled]="!getMainTopicItem(item)?.id"
[attr.aria-label]="
getTopicAriaLabel(getMainTopicItem(item), [item.year])
"
[appComponentTooltip]="AppTopicTooltipComponent"
[tooltipInputs]="{ topicId: getMainTopicItem(item)?.id }"
[tooltipInputs]="
getTopicTooltipInputs(getMainTopicItem(item), [
item.year,
])
"
[tooltipMaxWidth]="'500px'"
(click)="
selectTopic(getMainTopicItem(item), [item.year])
@@ -217,6 +224,16 @@
[color]="getTopicColor(topic)"
[disabled]="!topic.id"
[active]="isTopicActiveByLegend(topic)"
[secondaryActionLabel]="
getTopicAction(topic, [item.year])?.label ?? null
"
[secondaryActionLink]="
getTopicAction(topic, [item.year])?.link ?? null
"
[secondaryActionQueryParams]="
getTopicAction(topic, [item.year])?.queryParams ??
null
"
(chipClick)="selectTopic(topic, [item.year])">
</app-topic-chip>
</ng-container>
@@ -288,8 +305,19 @@
type="button"
class="main-topic-button"
[disabled]="!phase.primaryTopic.id"
[attr.aria-label]="
getTopicAriaLabel(
phase.primaryTopic,
getPhaseYears(phase)
)
"
[appComponentTooltip]="AppTopicTooltipComponent"
[tooltipInputs]="{ topicId: phase.primaryTopic.id }"
[tooltipInputs]="
getTopicTooltipInputs(
phase.primaryTopic,
getPhaseYears(phase)
)
"
[tooltipMaxWidth]="'500px'"
(click)="
selectTopic(phase.primaryTopic, getPhaseYears(phase))
@@ -317,6 +345,16 @@
[color]="getTopicColor(topic)"
[disabled]="!topic.id"
[active]="isTopicActiveByLegend(topic)"
[secondaryActionLabel]="
getTopicAction(topic, getPhaseYears(phase))?.label ?? null
"
[secondaryActionLink]="
getTopicAction(topic, getPhaseYears(phase))?.link ?? null
"
[secondaryActionQueryParams]="
getTopicAction(topic, getPhaseYears(phase))
?.queryParams ?? null
"
(chipClick)="selectTopic(topic, getPhaseYears(phase))">
</app-topic-chip>
</ng-container>
@@ -396,6 +434,16 @@
[color]="getTopicColor(topic)"
[disabled]="!topic.id"
[active]="isTopicActiveByLegend(topic)"
[secondaryActionLabel]="
getTopicAction(topic, [year.year])?.label ?? null
"
[secondaryActionLink]="
getTopicAction(topic, [year.year])?.link ?? null
"
[secondaryActionQueryParams]="
getTopicAction(topic, [year.year])?.queryParams ??
null
"
(chipClick)="selectTopic(topic, [year.year])">
</app-topic-chip>
</ng-container>
@@ -30,6 +30,7 @@ import {
toggleTopicLegendSubfieldSelection,
} from '../../../../resolvers/utils/topic-legend';
import { buildTopicHierarchyTooltip } from '../../../../resolvers/utils/topic-tooltip';
import { workQueryParamKeys } from '../../../../resolvers/work-page.resolver';
export interface TopicTimelineTopic {
id?: string;
@@ -92,6 +93,19 @@ interface TimelineScrollAnchor {
scrollLeft: number;
}
interface TimelineTopicAction {
label: string;
link: unknown[];
queryParams: Record<string, string | number | number[]>;
}
interface TimelineTopicTooltipInputs {
topicId: string | undefined;
secondaryActionLabel: string | null;
secondaryActionLink: unknown[] | null;
secondaryActionQueryParams: Record<string, string | number | number[]> | null;
}
@Component({
selector: 'app-research-timeline',
standalone: true,
@@ -123,6 +137,8 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
@Input() subfieldLegendVisible = true;
@Input() subfieldLegendExpanded = false;
@Input() wordCloudLegendTopics: TopicLegendTopic[] = [];
@Input() personPublicationsLink: unknown[] | null = null;
@Input() personName = '';
@Output() viewModeChange = new EventEmitter<TimelineViewMode>();
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
@@ -146,6 +162,11 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
private readonly displayedPhaseTopicLimit = 4;
private readonly scrollRestoreThreshold = 24;
private readonly expandedPhaseIds = new Set<string>();
private readonly topicActionCache = new Map<string, TimelineTopicAction>();
private readonly tooltipInputsCache = new Map<
string,
TimelineTopicTooltipInputs
>();
activeLegendFieldIds: ReadonlySet<string> = new Set();
activeLegendSubfieldIds: ReadonlySet<string> = new Set();
@@ -169,6 +190,11 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
if (changes['elements'] || changes['startYear'] || changes['endYear']) {
this.applyInputYearRange();
}
if (changes['personName'] || changes['personPublicationsLink']) {
this.topicActionCache.clear();
this.tooltipInputsCache.clear();
}
}
ngAfterViewChecked(): void {
@@ -330,6 +356,85 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return phase.years.map((year) => year.year);
}
getTopicAction(
topic: TopicTimelineTopic | undefined,
years: number[],
): TimelineTopicAction | null {
if (!this.personPublicationsLink || !topic?.id || years.length === 0) {
return null;
}
const selectedYears = this.normalizeSelectedYears(years);
const cacheKey = `${topic.id}|${selectedYears.join(',')}`;
const cached = this.topicActionCache.get(cacheKey);
if (cached) {
return cached;
}
const person = this.personName || 'dieser Person';
const action: TimelineTopicAction = {
label: `Publikationen von ${person} ${this.formatYearRange(selectedYears)}`,
link: this.personPublicationsLink,
queryParams: {
[workQueryParamKeys.page]: 0,
[workQueryParamKeys.years]: selectedYears,
[workQueryParamKeys.topicId]: topic.id,
},
};
this.topicActionCache.set(cacheKey, action);
return action;
}
getTopicTooltipInputs(
topic: TopicTimelineTopic | undefined,
years: number[],
): TimelineTopicTooltipInputs {
const action = this.getTopicAction(topic, years);
const cacheKey = `${topic?.id ?? ''}|${years.join(',')}`;
const cached = this.tooltipInputsCache.get(cacheKey);
if (cached) {
return cached;
}
const inputs: TimelineTopicTooltipInputs = {
topicId: topic?.id,
secondaryActionLabel: action?.label ?? null,
secondaryActionLink: action?.link ?? null,
secondaryActionQueryParams: action?.queryParams ?? null,
};
this.tooltipInputsCache.set(cacheKey, inputs);
return inputs;
}
getTopicAriaLabel(
topic: TopicTimelineTopic | undefined,
years: number[],
): string | null {
if (!topic?.id || years.length === 0) {
return null;
}
const person = this.personName || 'dieser Person';
const selectedYears = this.normalizeSelectedYears(years);
return `Publikationen von ${person} zum Thema ${topic.name} ${this.formatYearRange(selectedYears)}`;
}
private formatYearRange(years: number[]): string {
const firstYear = years[0];
const lastYear = years[years.length - 1];
return firstYear === lastYear
? `(${firstYear})`
: `(${firstYear}–${lastYear})`;
}
getYearPublicationTooltip(item: TopicTimelineElement): string {
return this.getPublicationTooltip(
item.publication_count,
@@ -15,8 +15,9 @@
[style.fontSize.px]="word.fontSize"
[style.fontWeight]="word.fontWeight"
[disabled]="!word.topicId"
[attr.aria-label]="wordAriaLabel(word)"
[appComponentTooltip]="AppTopicTooltipComponent"
[tooltipInputs]="{ topicId: word.rawTopicId }"
[tooltipInputs]="tooltipInputsFor(word)"
[tooltipDisabled]="!word.rawTopicId"
[tooltipMaxWidth]="'500px'"
(click)="selectWord(word)">
@@ -8,6 +8,14 @@ import {
getTopicLegendSubfieldId,
TopicLegendTopic,
} from '../../../../resolvers/utils/topic-legend';
import { workQueryParamKeys } from '../../../../resolvers/work-page.resolver';
interface WordTooltipInputs {
topicId: string;
secondaryActionLabel: string | null;
secondaryActionLink: unknown[] | null;
secondaryActionQueryParams: Record<string, string | number>;
}
export interface WordCloudTopicOccurrence {
name: string;
@@ -158,7 +166,24 @@ function stripOpenAlexId(id: string | null | undefined): string {
export class ResearchWordcloudComponent {
readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
@Input() words: WordCloudWord[] = [];
@Input() set words(value: WordCloudWord[]) {
this._words = value;
this.rebuildTooltipInputs();
}
get words(): WordCloudWord[] {
return this._words;
}
@Input() set personPublicationsLink(value: unknown[] | null) {
this._personPublicationsLink = value;
this.rebuildTooltipInputs();
}
@Input() set personName(value: string) {
this._personName = value;
this.rebuildTooltipInputs();
}
@Input() loading = false;
@Input() loadFailed = false;
@Input() activeFieldIds: ReadonlySet<string> = new Set();
@@ -166,6 +191,11 @@ export class ResearchWordcloudComponent {
@Output() wordSelect = new EventEmitter<WordCloudWord>();
private _words: WordCloudWord[] = [];
private _personPublicationsLink: unknown[] | null = null;
private _personName = '';
private tooltipInputsByTopic = new Map<string, WordTooltipInputs>();
selectWord(word: WordCloudWord): void {
if (!word.topicId) {
return;
@@ -181,4 +211,38 @@ export class ResearchWordcloudComponent {
this.activeSubfieldIds.has(word.subfieldLegendId))
);
}
tooltipInputsFor(word: WordCloudWord): WordTooltipInputs | null {
return this.tooltipInputsByTopic.get(word.topicId) ?? null;
}
wordAriaLabel(word: WordCloudWord): string {
return this._personName
? `Publikationen von ${this._personName} zum Thema ${word.name}`
: `Publikationen dieser Person zum Thema ${word.name}`;
}
private rebuildTooltipInputs(): void {
const label = this._personName
? `Publikationen von ${this._personName}`
: 'Publikationen dieser Person';
const link = this._personPublicationsLink;
this.tooltipInputsByTopic = new Map(
this._words
.filter((word) => word.topicId)
.map((word) => [
word.topicId,
{
topicId: word.rawTopicId,
secondaryActionLabel: link ? label : null,
secondaryActionLink: link,
secondaryActionQueryParams: {
[workQueryParamKeys.page]: 0,
[workQueryParamKeys.topicId]: word.topicId,
},
},
]),
);
}
}
@@ -12,6 +12,8 @@
[subfieldLegendVisible]="timelineLegendVisible"
[subfieldLegendExpanded]="timelineLegendExpanded"
[wordCloudLegendTopics]="wordCloudLegendTopics"
[personName]="personName"
[personPublicationsLink]="personPublicationsLink"
(viewModeChange)="onTimelineViewModeChange($event)"
(yearRangeChange)="onTimelineYearRangeChange($event)"
(subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)"
@@ -27,6 +29,8 @@
[loadFailed]="wordCloudLoadFailed"
[activeFieldIds]="activeLegendFieldIds"
[activeSubfieldIds]="activeLegendSubfieldIds"
[personName]="personName"
[personPublicationsLink]="personPublicationsLink"
(wordSelect)="onWordClick($event)" />
</app-research-timeline>
</section>
@@ -1,7 +1,7 @@
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
import { combineLatest, distinctUntilChanged, map, of, switchMap } from 'rxjs';
import { TopicCount, TopicsByYear, WorksService } from '../../api';
import {
@@ -23,6 +23,7 @@ import {
TopicLegendSelectionState,
TopicLegendTopic,
} from '../../resolvers/utils/topic-legend';
import { PersonDataResolved } from '../../resolvers/person.resolver';
@Component({
selector: 'app-person-overview',
@@ -69,6 +70,8 @@ export class PersonOverviewComponent implements OnInit {
wordCloudLoadFailed = false;
activeLegendFieldIds: ReadonlySet<string> = new Set();
activeLegendSubfieldIds: ReadonlySet<string> = new Set();
personName = '';
personPublicationsLink: unknown[] | null = null;
private rawTopicOccurrences: WordCloudTopicOccurrence[] = [];
@@ -80,10 +83,16 @@ export class PersonOverviewComponent implements OnInit {
takeUntilDestroyed(this.destroyRef),
)
.subscribe((authorId) => {
this.personPublicationsLink =
authorId && authorId !== '0'
? ['/person', authorId, 'publications']
: null;
this.loadTopicTimeline(authorId);
this.loadWordCloud(authorId);
});
this.loadPersonName();
this.route.queryParamMap
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((queryParams) => {
@@ -337,6 +346,25 @@ export class PersonOverviewComponent implements OnInit {
this.timelineEarlierYearsLoadFailed = false;
}
private loadPersonName(): void {
combineLatest(this.route.pathFromRoot.map((route) => route.data))
.pipe(
map((dataEntries) =>
dataEntries
.map((data) => data['personData'] as PersonDataResolved | undefined)
.find((resolved): resolved is PersonDataResolved =>
Boolean(resolved),
),
),
distinctUntilChanged(),
switchMap((resolved) => resolved?.personData$ ?? of(null)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe((response) => {
this.personName = response?.results?.[0]?.display_name ?? '';
});
}
private loadWordCloud(authorId: string): void {
if (!authorId || authorId === '0') {
this.wordCloudWords = [];
@@ -130,6 +130,8 @@
<app-person-interesting
[topics]="primaryTopicCounts()"
[loading]="isTopicsLoading()"
[personName]="personName()"
[personPublicationsLink]="personPublicationsLink()"
(tagClick)="onInterestingTagClick($event)"></app-person-interesting>
</section>
@if (this.links()) {
@@ -5,6 +5,7 @@ import {
inject,
signal,
DestroyRef,
ElementRef,
input,
viewChild,
} from '@angular/core';
@@ -18,11 +19,20 @@ import { MatTabsModule } from '@angular/material/tabs';
import { MatTooltipModule } from '@angular/material/tooltip';
import {
ActivatedRoute,
NavigationEnd,
Router,
RouterModule,
RouterOutlet,
} from '@angular/router';
import { of, switchMap, finalize, map, catchError, combineLatest } from 'rxjs';
import {
of,
switchMap,
finalize,
map,
catchError,
combineLatest,
filter,
} from 'rxjs';
import { PersonInterestingComponent } from '../person-interesting/person-interesting.component';
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
@@ -82,11 +92,28 @@ export class PersonComponent {
() => this.navBar()?.activeLink() ?? null,
);
private readonly tabPanelElement = viewChild('tabPanel', {
read: ElementRef,
});
private publicationFilterKey: string | null = null;
constructor() {
this.bookmarkService
.load()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe();
this.router.events
.pipe(
filter(
(event): event is NavigationEnd => event instanceof NavigationEnd,
),
takeUntilDestroyed(this.destroyRef),
)
.subscribe((event) =>
this.scrollToPanelOnFilterChange(event.urlAfterRedirects),
);
}
readonly params = toSignal(this.activatedRoute.paramMap);
@@ -169,6 +196,13 @@ export class PersonComponent {
readonly displayName = computed(
() => this.person()?.display_name ?? 'Unbekannte Person',
);
readonly personName = computed(() => this.person()?.display_name ?? '');
readonly personPublicationsLink = computed<unknown[] | null>(() => {
const authorId = this.authorId();
return authorId ? ['/person', authorId, 'publications'] : null;
});
readonly initials = computed(() => this.buildInitials(this.displayName()));
readonly primaryAffiliation = computed(
() => this.person()?.affiliations?.[0] ?? null,
@@ -368,6 +402,46 @@ export class PersonComponent {
});
}
private scrollToPanelOnFilterChange(url: string): void {
const { queryParams } = this.router.parseUrl(url);
const filterKey = [workQueryParamKeys.topicId, workQueryParamKeys.years]
.map((key) => {
const value = queryParams[key];
return Array.isArray(value) ? value.join(',') : (value ?? '');
})
.join('|');
const previousFilterKey = this.publicationFilterKey;
this.publicationFilterKey = filterKey;
const hasFilter = filterKey !== '|';
const isFirstNavigation = previousFilterKey === null;
if (isFirstNavigation || !hasFilter || filterKey === previousFilterKey) {
return;
}
this.scrollPanelIntoView();
}
private scrollPanelIntoView(): void {
const scrollToPanel = (): void => {
this.tabPanelElement()?.nativeElement.scrollIntoView({
behavior: 'smooth',
block: 'start',
});
};
requestAnimationFrame(scrollToPanel);
setTimeout(() => {
const panel = this.tabPanelElement();
if (panel && panel.nativeElement.getBoundingClientRect().top > 8) {
scrollToPanel();
}
}, 400);
}
private getId(key: string): string | null {
const ids = this.person()?.ids as Record<string, string> | undefined;
if (!ids) {
@@ -40,13 +40,24 @@
<mat-card-footer>
<mat-card-actions class="card-actions">
@if (hasSecondaryAction()) {
<a
class="card-action"
[routerLink]="secondaryActionLink()"
[queryParams]="secondaryActionQueryParams()"
matButton="outlined"
(click)="$event.stopPropagation()">
<mat-icon>{{ secondaryActionIcon() }}</mat-icon>
{{ secondaryActionLabel() }}
</a>
}
<a
class="card-action"
[routerLink]="['/topic', stripOpenAlexId(topic.id), 'publications']"
matButton="outlined"
(click)="$event.stopPropagation()">
<mat-icon>menu_book</mat-icon>
Publikationen
{{ publicationsActionLabel() }}
</a>
</mat-card-actions>
</mat-card-footer>
@@ -96,6 +96,7 @@ mat-card-content {
.card-actions {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
@@ -3,7 +3,7 @@ import { Topic } from '../../../api';
import { MatCardModule } from '@angular/material/card';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
import { RouterModule } from '@angular/router';
import { Params, RouterModule } from '@angular/router';
import { DecimalPipe } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
@@ -27,6 +27,31 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
export class AppTopicCardComponent {
topic = input.required<Topic>();
/**
* Optional extra footer action, e.g. "Publikationen von <Person>". Only
* rendered when both label and link are given.
*/
secondaryActionLabel = input<string | null>(null);
secondaryActionIcon = input<string>('person_search');
secondaryActionLink = input<unknown[] | string | null>(null);
secondaryActionQueryParams = input<Params | null>(null);
hasSecondaryAction = computed(
() =>
Boolean(this.secondaryActionLabel()) &&
Boolean(this.secondaryActionLink()),
);
/**
* Without a secondary action "Publikationen" is unambiguous. Next to a
* person-scoped action it is not, so the scope becomes explicit.
*/
publicationsActionLabel = computed(() =>
this.hasSecondaryAction()
? 'Alle Publikationen zum Thema'
: 'Publikationen',
);
stripOpenAlexId(id: string | null | undefined): string | undefined {
if (!id) {
return undefined;
@@ -1,5 +1,10 @@
@let topic = this._topic();
@if (topic) {
<app-topic-card [topic]="topic" />
<app-topic-card
[topic]="topic"
[secondaryActionLabel]="secondaryActionLabel()"
[secondaryActionIcon]="secondaryActionIcon()"
[secondaryActionLink]="secondaryActionLink()"
[secondaryActionQueryParams]="secondaryActionQueryParams()" />
}
@@ -1,4 +1,5 @@
import { Component, effect, inject, input, signal } from '@angular/core';
import { Params } from '@angular/router';
import { Topic, TopicsV2Service } from '../../../api';
import { AppTopicCardComponent } from '../app-topic-card/app-topic-card.component';
@@ -14,6 +15,11 @@ export class AppTopicTooltipComponent {
topicId = input<string | null | undefined>(undefined);
topic = input<Topic | null | undefined>(undefined);
secondaryActionLabel = input<string | null>(null);
secondaryActionIcon = input<string>('person_search');
secondaryActionLink = input<unknown[] | string | null>(null);
secondaryActionQueryParams = input<Params | null>(null);
_topic = signal<Topic | undefined>(undefined);
_isLoading = signal<boolean>(false);
@@ -1,6 +1,7 @@
import { Component, computed, input, output } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { Params } from '@angular/router';
import { Topic } from '../../../api';
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
import { AppTopicTooltipComponent } from '../app-topic-tooltip/app-topic-tooltip.component';
@@ -102,6 +103,10 @@ export class TopicChipComponent {
descriptionTooltipTarget = input<TopicChipTooltipTarget>('label');
topicId = input<string | null | undefined>(undefined);
topic = input<Topic | null | undefined>(undefined);
secondaryActionLabel = input<string | null>(null);
secondaryActionIcon = input<string>('person_search');
secondaryActionLink = input<unknown[] | string | null>(null);
secondaryActionQueryParams = input<Params | null>(null);
chipClick = output<void>();
@@ -188,6 +193,10 @@ export class TopicChipComponent {
return {
topic: this.topicObject(),
topicId: this.topicId() ?? this.topic()?.id ?? undefined,
secondaryActionLabel: this.secondaryActionLabel(),
secondaryActionIcon: this.secondaryActionIcon(),
secondaryActionLink: this.secondaryActionLink(),
secondaryActionQueryParams: this.secondaryActionQueryParams(),
};
});