From ae80f0f8124c7816a86866f8b8480184f4979348 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sun, 16 Aug 2026 15:05:06 +0200 Subject: [PATCH 1/3] feat(topic-card, person-overview): add optional secondary action to the topic card to link to person's publications --- .../research-wordcloud.component.html | 3 +- .../research-wordcloud.component.ts | 66 ++++++++++++++++++- .../person-overview.component.html | 2 + .../person-overview.component.ts | 30 ++++++++- .../app-topic-card.component.html | 13 +++- .../app-topic-card.component.scss | 1 + .../app-topic-card.component.ts | 27 +++++++- .../app-topic-tooltip.component.html | 7 +- .../app-topic-tooltip.component.ts | 6 ++ 9 files changed, 149 insertions(+), 6 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.html b/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.html index a55a72c2..80fdda5d 100644 --- a/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.html +++ b/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.html @@ -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)"> diff --git a/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.ts b/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.ts index ceb3c06b..e6824385 100644 --- a/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-wordcloud/research-wordcloud.component.ts @@ -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; +} 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 = new Set(); @@ -166,6 +191,11 @@ export class ResearchWordcloudComponent { @Output() wordSelect = new EventEmitter(); + private _words: WordCloudWord[] = []; + private _personPublicationsLink: unknown[] | null = null; + private _personName = ''; + private tooltipInputsByTopic = new Map(); + 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, + }, + }, + ]), + ); + } } 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 dc263735..28a07e63 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -27,6 +27,8 @@ [loadFailed]="wordCloudLoadFailed" [activeFieldIds]="activeLegendFieldIds" [activeSubfieldIds]="activeLegendSubfieldIds" + [personName]="personName" + [personPublicationsLink]="personPublicationsLink" (wordSelect)="onWordClick($event)" /> diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index 9212d823..1aeb032c 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -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 = new Set(); activeLegendSubfieldIds: ReadonlySet = 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 = []; diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html index f302297d..bb02e886 100644 --- a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html +++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html @@ -40,13 +40,24 @@ + @if (hasSecondaryAction()) { + + {{ secondaryActionIcon() }} + {{ secondaryActionLabel() }} + + } menu_book - Publikationen + {{ publicationsActionLabel() }} diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss index 6873883d..834030be 100644 --- a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss +++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss @@ -96,6 +96,7 @@ mat-card-content { .card-actions { display: flex; + flex-direction: column; gap: 0.5rem; } diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts index f6e204c9..d4b3fab4 100644 --- a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts +++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts @@ -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(); + /** + * Optional extra footer action, e.g. "Publikationen von ". Only + * rendered when both label and link are given. + */ + secondaryActionLabel = input(null); + secondaryActionIcon = input('person_search'); + secondaryActionLink = input(null); + secondaryActionQueryParams = input(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; diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html index e34a20b3..0ebd3b61 100644 --- a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html +++ b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html @@ -1,5 +1,10 @@ @let topic = this._topic(); @if (topic) { - + } diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts index 2315bad7..19338d62 100644 --- a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts +++ b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts @@ -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(undefined); topic = input(undefined); + secondaryActionLabel = input(null); + secondaryActionIcon = input('person_search'); + secondaryActionLink = input(null); + secondaryActionQueryParams = input(null); + _topic = signal(undefined); _isLoading = signal(false); -- 2.56.1 From ce218cbfa103a39c09c8c545e54f3de3a4a821c0 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Mon, 17 Aug 2026 12:49:57 +0200 Subject: [PATCH 2/3] feat(research-timeline): add secondary action to topic tooltip --- .../research-timeline.component.html | 52 ++++++++- .../research-timeline.component.ts | 105 ++++++++++++++++++ .../person-overview.component.html | 2 + .../ui/topic-chip/topic-chip.component.ts | 9 ++ 4 files changed, 166 insertions(+), 2 deletions(-) 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(), }; }); -- 2.56.1 From a8db8194cfbe6d50b2d256863e91f37fd06d7261 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Mon, 17 Aug 2026 13:41:07 +0200 Subject: [PATCH 3/3] feat(person-overview): add secondary action to tooltips in 'person interesting' section --- .../directives/component-tooltip.directive.ts | 26 +++++++ .../person-interesting.component.html | 3 + .../person-interesting.component.ts | 41 ++++++++++ .../app/modules/person/person.component.html | 2 + .../app/modules/person/person.component.ts | 76 ++++++++++++++++++- 5 files changed, 147 insertions(+), 1 deletion(-) diff --git a/webapp/src/app/directives/component-tooltip.directive.ts b/webapp/src/app/directives/component-tooltip.directive.ts index daccfa52..2f9e8735 100644 --- a/webapp/src/app/directives/component-tooltip.directive.ts +++ b/webapp/src/app/directives/component-tooltip.directive.ts @@ -45,6 +45,7 @@ export class ComponentTooltipDirective implements OnDestroy { private componentRef: ComponentRef | null = null; private showTimeout?: ReturnType; private hideTimeout?: ReturnType; + private dismissTimeout?: ReturnType; private isOverHost = false; private isOverOverlay = false; @@ -84,6 +85,24 @@ export class ComponentTooltipDirective 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 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 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 implements OnDestroy { ngOnDestroy(): void { clearTimeout(this.showTimeout); clearTimeout(this.hideTimeout); + clearTimeout(this.dismissTimeout); this.overlayRef?.dispose(); } } diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index 87a7ed5e..5ac0ea97 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -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)"> diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts index ad3307bf..dc1fc4d3 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -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; +} + const MAX_TAGS = 5; @Component({ @@ -69,6 +76,10 @@ export class PersonInterestingComponent implements OnInit { readonly topics = input(null); readonly loading = input(false); + + readonly personPublicationsLink = input(null); + readonly personName = input(''); + readonly legendExpanded = signal(false); readonly activeLegendFieldIds = signal>(new Set()); readonly activeLegendSubfieldIds = signal>(new Set()); @@ -142,6 +153,36 @@ export class PersonInterestingComponent implements OnInit { }); } + private readonly tagActions = computed(() => { + const actions = new Map(); + 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({ diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index 1fd0a34b..40abbf6b 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -130,6 +130,8 @@ @if (this.links()) { diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index f32588d1..afd17359 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -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(() => { + 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 | undefined; if (!ids) { -- 2.56.1