From 512356e1062490935c97b3d7ae03cbe75ba09fc1 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 26 Jun 2026 13:58:18 +0200 Subject: [PATCH] topic-legend: highlight selected fields and topic --- .../person-interesting.component.html | 6 ++ .../person-interesting.component.ts | 43 +++++++- .../research-timeline.component.html | 8 ++ .../research-timeline.component.ts | 32 +++++- .../ui/topic-chip/topic-chip.component.scss | 33 +++++- .../topic-legend/topic-legend.component.html | 25 +++-- .../topic-legend/topic-legend.component.scss | 102 ++++++++++++++++++ .../ui/topic-legend/topic-legend.component.ts | 53 ++++++++- webapp/src/app/shared/utils/topic-legend.ts | 38 ++++++- 9 files changed, 324 insertions(+), 16 deletions(-) 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 bc015605..18999c00 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -11,10 +11,15 @@
@@ -29,6 +34,7 @@ [domainName]="tag.domainName" [color]="tag.color" [disabled]="!tag.id" + [active]="isTagActive(tag)" 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 b4b67654..ced9f9d0 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -17,7 +17,14 @@ import { TopicCount } from '../../api'; import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component'; import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component'; import { topicHierarchyColor } from '../../shared/utils/topic-colors'; -import { buildTopicLegendGroups } from '../../shared/utils/topic-legend'; +import { + buildTopicLegendGroups, + getTopicLegendFieldId, + getTopicLegendSubfieldId, + TopicLegendGroup, + TopicLegendSubfieldSelection, + toggleTopicLegendSelection, +} from '../../shared/utils/topic-legend'; interface InterestTag { id: string; @@ -59,6 +66,8 @@ export class PersonInterestingComponent implements OnInit { readonly topics = input(null); readonly legendExpanded = signal(false); + readonly activeLegendFieldIds = signal>(new Set()); + readonly activeLegendSubfieldIds = signal>(new Set()); readonly tagClick = output<{ id: string; name: string }>(); @@ -144,6 +153,38 @@ export class PersonInterestingComponent implements OnInit { }); } + onLegendFieldToggle(group: TopicLegendGroup): void { + this.activeLegendFieldIds.set( + toggleTopicLegendSelection(this.activeLegendFieldIds(), group.id), + ); + } + + onLegendSubfieldToggle(selection: TopicLegendSubfieldSelection): void { + this.activeLegendSubfieldIds.set( + toggleTopicLegendSelection( + this.activeLegendSubfieldIds(), + selection.item.id, + ), + ); + } + + isTagActive(tag: InterestTag): boolean { + const fieldLegendId = getTopicLegendFieldId({ + field_id: tag.fieldId, + field_name: tag.fieldName, + }); + const subfieldLegendId = getTopicLegendSubfieldId({ + subfield_id: tag.subfieldId, + subfield_name: tag.subfieldName, + }); + + return ( + this.activeLegendFieldIds().has(fieldLegendId) || + (subfieldLegendId.length > 0 && + this.activeLegendSubfieldIds().has(subfieldLegendId)) + ); + } + private parseBooleanQueryParam( value: string | null, fallback: boolean, 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 fb4d9f42..55f0d938 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 @@ -12,6 +12,11 @@ [visible]="subfieldLegendVisible" [expanded]="subfieldLegendExpanded" [collapsedGroupLimit]="3" + [selectable]="true" + [activeFieldIds]="activeLegendFieldIds" + [activeSubfieldIds]="activeLegendSubfieldIds" + (fieldToggle)="onLegendFieldToggle($event)" + (subfieldToggle)="onLegendSubfieldToggle($event)" (visibleChange)="onSubfieldLegendVisibleChange($event)" (expandedChange)="onSubfieldLegendExpandedChange($event)"> @@ -254,6 +259,7 @@ [countTooltip]="getYearTopicCountTooltip(topic, item)" [color]="getTopicColor(topic)" [disabled]="!topic.id" + [active]="isTopicActiveByLegend(topic)" (chipClick)="selectTopic(topic, [item.year])"> @@ -354,6 +360,7 @@ [countTooltip]="getPhaseTopicCountTooltip(topic, phase)" [color]="getTopicColor(topic)" [disabled]="!topic.id" + [active]="isTopicActiveByLegend(topic)" (chipClick)="selectTopic(topic, getPhaseYears(phase))"> @@ -431,6 +438,7 @@ [countTooltip]="getYearTopicCountTooltip(topic, year)" [color]="getTopicColor(topic)" [disabled]="!topic.id" + [active]="isTopicActiveByLegend(topic)" (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 9d88ff2d..09392acc 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 @@ -17,7 +17,11 @@ import { TopicLegendComponent } from '../../../../shared/ui/topic-legend/topic-l import { topicHierarchyColor } from '../../../../shared/utils/topic-colors'; import { buildTopicLegendGroups, + getTopicLegendFieldId, + getTopicLegendSubfieldId, TopicLegendGroup, + TopicLegendSubfieldSelection, + toggleTopicLegendSelection, } from '../../../../shared/utils/topic-legend'; import { buildTopicHierarchyTooltip } from '../../../../shared/utils/topic-tooltip'; @@ -130,6 +134,8 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { private readonly displayedPhaseTopicLimit = 4; private readonly scrollRestoreThreshold = 24; private readonly expandedPhaseIds = new Set(); + activeLegendFieldIds: ReadonlySet = new Set(); + activeLegendSubfieldIds: ReadonlySet = new Set(); private pendingTimelineScrollAnchor: TimelineScrollAnchor | undefined; @@ -423,6 +429,31 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { this.subfieldLegendVisibleChange.emit(this.subfieldLegendVisible); } + onLegendFieldToggle(group: TopicLegendGroup): void { + this.activeLegendFieldIds = toggleTopicLegendSelection( + this.activeLegendFieldIds, + group.id, + ); + } + + onLegendSubfieldToggle(selection: TopicLegendSubfieldSelection): void { + this.activeLegendSubfieldIds = toggleTopicLegendSelection( + this.activeLegendSubfieldIds, + selection.item.id, + ); + } + + isTopicActiveByLegend(topic: TopicTimelineTopic): boolean { + const fieldLegendId = getTopicLegendFieldId(topic); + const subfieldLegendId = getTopicLegendSubfieldId(topic); + + return ( + this.activeLegendFieldIds.has(fieldLegendId) || + (subfieldLegendId.length > 0 && + this.activeLegendSubfieldIds.has(subfieldLegendId)) + ); + } + trackByYear(_: number, item: TopicTimelineElement): number { return item.year; } @@ -558,7 +589,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { return `im Zeitraum ${this.getPhaseYearLabel(phase)}`; } - private get earlierYearsColumnCount(): number { return this.showEarlierYearsControl ? 1 : 0; } diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss index fb757f9d..7a9dffe9 100644 --- a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss @@ -61,13 +61,38 @@ :host(.topic-chip--active.topic-chip--normal) .topic-chip__button { border-color: var(--topic-color); - box-shadow: 0 0 0 2px color-mix(in srgb, var(--topic-color) 26%, transparent); + background: color-mix(in srgb, var(--topic-color) 27%, #ffffff); + color: color-mix(in srgb, var(--topic-color) 40%, #07163d); + box-shadow: + inset 0 0 0 1px var(--topic-color), + 0 0 0 2px #ffffff, + 0 0 0 4px color-mix(in srgb, var(--topic-color) 48%, transparent), + 0 5px 12px rgba(15, 23, 42, 0.16); + + &:hover:not(:disabled) { + box-shadow: + inset 0 0 0 1px var(--topic-color), + 0 0 0 2px #ffffff, + 0 0 0 4px color-mix(in srgb, var(--topic-color) 56%, transparent), + 0 7px 14px rgba(15, 23, 42, 0.18); + } } :host(.topic-chip--active.topic-chip--mini) .topic-chip__button { - background: color-mix(in srgb, var(--topic-color) 24%, #ffffff); - color: var(--topic-text); - box-shadow: 0 0 0 1.5px var(--topic-color); + background: color-mix(in srgb, var(--topic-color) 32%, #ffffff); + color: color-mix(in srgb, var(--topic-color) 42%, #07163d); + box-shadow: + 0 0 0 1px #ffffff, + 0 0 0 3px color-mix(in srgb, var(--topic-color) 72%, transparent); + font-weight: 800; +} + +:host(.topic-chip--active.topic-chip--normal) .topic-chip__count { + background: #ffffff; + color: color-mix(in srgb, var(--topic-color) 46%, #07163d); + box-shadow: + inset 0 0 0 1px color-mix(in srgb, var(--topic-color) 72%, transparent), + 0 1px 4px rgba(15, 23, 42, 0.18); } .topic-chip__label { diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html index 34c724d1..115a8e3a 100644 --- a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html @@ -3,6 +3,7 @@ class="topic-legend" [class.topic-legend-compact]="variant === 'compact'" [class.topic-legend-expanded]="expanded" + [class.topic-legend-selectable]="selectable" aria-label="Aktuell sichtbare Themenbereiche">
@@ -45,30 +46,40 @@
- + - + matTooltipPosition="above" + (click)="toggleSubfield(group, item)"> {{ item.name }} - +
diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss index fa9fca76..666ca903 100644 --- a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss @@ -110,11 +110,39 @@ background: #fbfdff; } +.topic-legend-group-active { + border-color: var(--legend-color, var(--topic-legend-accent)); + background: color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 10%, + #fbfdff + ); + box-shadow: + inset 0 0 0 1px + color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 55%, + transparent + ), + 0 0 0 2px + color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 22%, + transparent + ); +} + .topic-legend-field { flex: 0 1 auto; min-width: 0; gap: 5px; + padding: 2px 4px; + appearance: none; + border: 0; + border-radius: 999px; + background: transparent; color: #07163d; + font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1.2; @@ -143,13 +171,87 @@ } .topic-legend-item { + display: inline-flex; + align-items: center; + padding: 2px 4px; + appearance: none; + border: 0; + border-radius: 999px; + background: transparent; color: #53617e; + font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1.25; cursor: help; } +.topic-legend-selectable { + .topic-legend-field, + .topic-legend-item { + cursor: pointer; + } + + .topic-legend-field:hover, + .topic-legend-item:hover { + background: color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 8%, + #ffffff + ); + } +} + +.topic-legend-field:focus-visible, +.topic-legend-item:focus-visible { + outline: 2px solid var(--topic-legend-accent); + outline-offset: 2px; +} + +.topic-legend-entry-active { + background: color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 24%, + #ffffff + ); + box-shadow: + inset 0 0 0 1px + color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 75%, + transparent + ), + 0 1px 3px rgba(15, 23, 42, 0.12); +} + +.topic-legend-field.topic-legend-entry-active { + color: color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 34%, + #07163d + ); +} + +.topic-legend-field.topic-legend-entry-active .topic-legend-dot { + box-shadow: + 0 0 0 2px #ffffff, + 0 0 0 4px + color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 82%, + transparent + ); +} + +.topic-legend-item.topic-legend-entry-active { + color: color-mix( + in srgb, + var(--legend-color, var(--topic-legend-accent)) 34%, + #07163d + ); + font-weight: 800; +} + .topic-legend-more-toggle { flex: 0 0 auto; padding: 0; diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts index 171ac204..e28a0311 100644 --- a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts @@ -2,7 +2,11 @@ import { CommonModule } from '@angular/common'; import { Component, EventEmitter, Input, Output } from '@angular/core'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { TopicLegendGroup, TopicLegendItem } from '../../utils/topic-legend'; +import { + TopicLegendGroup, + TopicLegendItem, + TopicLegendSubfieldSelection, +} from '../../utils/topic-legend'; export type TopicLegendVariant = 'default' | 'compact'; @@ -24,9 +28,14 @@ export class TopicLegendComponent { @Input() showVisibilityToggle = true; @Input() collapsedGroupLimit = 3; @Input() variant: TopicLegendVariant = 'default'; + @Input() selectable = false; + @Input() activeFieldIds: ReadonlySet | readonly string[] = []; + @Input() activeSubfieldIds: ReadonlySet | readonly string[] = []; @Output() visibleChange = new EventEmitter(); @Output() expandedChange = new EventEmitter(); + @Output() fieldToggle = new EventEmitter(); + @Output() subfieldToggle = new EventEmitter(); get hasGroups(): boolean { return this.groups.length > 0; @@ -66,6 +75,37 @@ export class TopicLegendComponent { this.expandedChange.emit(!this.expanded); } + toggleField(group: TopicLegendGroup): void { + if (!this.selectable) { + return; + } + + this.fieldToggle.emit(group); + } + + toggleSubfield(group: TopicLegendGroup, item: TopicLegendItem): void { + if (!this.selectable) { + return; + } + + this.subfieldToggle.emit({ group, item }); + } + + isFieldActive(group: TopicLegendGroup): boolean { + return this.isActiveLegendId(this.activeFieldIds, group.id); + } + + isSubfieldActive(item: TopicLegendItem): boolean { + return this.isActiveLegendId(this.activeSubfieldIds, item.id); + } + + isGroupActive(group: TopicLegendGroup): boolean { + return ( + this.isFieldActive(group) || + group.items.some((item) => this.isSubfieldActive(item)) + ); + } + trackByGroup(_: number, group: TopicLegendGroup): string { return group.id; } @@ -73,4 +113,15 @@ export class TopicLegendComponent { trackByItem(_: number, item: TopicLegendItem): string { return item.id; } + + private isActiveLegendId( + activeIds: ReadonlySet | readonly string[], + id: string, + ): boolean { + if ('has' in activeIds) { + return activeIds.has(id); + } + + return activeIds.includes(id); + } } diff --git a/webapp/src/app/shared/utils/topic-legend.ts b/webapp/src/app/shared/utils/topic-legend.ts index a54779c3..d297cba3 100644 --- a/webapp/src/app/shared/utils/topic-legend.ts +++ b/webapp/src/app/shared/utils/topic-legend.ts @@ -26,6 +26,40 @@ export interface TopicLegendGroup { items: TopicLegendItem[]; } +export interface TopicLegendSubfieldSelection { + group: TopicLegendGroup; + item: TopicLegendItem; +} + +export function getTopicLegendFieldId(topic: TopicLegendTopic): string { + const fieldName = normalizeLegendValue(topic.field_name) ?? 'Ohne Fachgebiet'; + + return topic.field_id ?? normalizeLegendKey(fieldName); +} + +export function getTopicLegendSubfieldId(topic: TopicLegendTopic): string { + const subfieldName = normalizeLegendValue(topic.subfield_name); + + return ( + topic.subfield_id ?? (subfieldName ? normalizeLegendKey(subfieldName) : '') + ); +} + +export function toggleTopicLegendSelection( + currentSelection: ReadonlySet, + id: string, +): Set { + const nextSelection = new Set(currentSelection); + + if (nextSelection.has(id)) { + nextSelection.delete(id); + return nextSelection; + } + + nextSelection.add(id); + return nextSelection; +} + export function buildTopicLegendGroups( topics: readonly TopicLegendTopic[], ): TopicLegendGroup[] { @@ -47,8 +81,8 @@ export function buildTopicLegendGroups( normalizeLegendValue(topic.domain_description) ?? ''; const subfieldDescription = normalizeLegendValue(topic.subfield_description) ?? ''; - const fieldKey = topic.field_id ?? normalizeLegendKey(fieldName); - const subfieldKey = topic.subfield_id ?? normalizeLegendKey(subfieldName); + const fieldKey = getTopicLegendFieldId(topic); + const subfieldKey = getTopicLegendSubfieldId(topic); if (!groups.has(fieldKey)) { groups.set(fieldKey, {