diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index 15ae9a94..6a6d05d0 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -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])"> @@ -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))"> @@ -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])"> diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts index 577de7b9..cd8e52ec 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts @@ -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; +} + +interface TimelineTopicTooltipInputs { + topicId: string | undefined; + secondaryActionLabel: string | null; + secondaryActionLink: unknown[] | null; + secondaryActionQueryParams: Record | 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(); @Output() yearRangeChange = new EventEmitter(); @@ -146,6 +162,11 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { private readonly displayedPhaseTopicLimit = 4; private readonly scrollRestoreThreshold = 24; private readonly expandedPhaseIds = new Set(); + private readonly topicActionCache = new Map(); + private readonly tooltipInputsCache = new Map< + string, + TimelineTopicTooltipInputs + >(); activeLegendFieldIds: ReadonlySet = new Set(); activeLegendSubfieldIds: ReadonlySet = 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, diff --git a/webapp/src/app/modules/person-overview/person-overview.component.html b/webapp/src/app/modules/person-overview/person-overview.component.html index 28a07e63..0596c00b 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -12,6 +12,8 @@ [subfieldLegendVisible]="timelineLegendVisible" [subfieldLegendExpanded]="timelineLegendExpanded" [wordCloudLegendTopics]="wordCloudLegendTopics" + [personName]="personName" + [personPublicationsLink]="personPublicationsLink" (viewModeChange)="onTimelineViewModeChange($event)" (yearRangeChange)="onTimelineYearRangeChange($event)" (subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)" diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts index 06e85d5b..90cc0ecb 100644 --- a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts @@ -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('label'); topicId = input(undefined); topic = input(undefined); + secondaryActionLabel = input(null); + secondaryActionIcon = input('person_search'); + secondaryActionLink = input(null); + secondaryActionQueryParams = input(null); chipClick = output(); @@ -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(), }; });