Timeline: show topic description on hover (frontend)
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-15 20:26:59 +02:00
parent 8949e6d1c6
commit bad95c65dd
3 changed files with 36 additions and 0 deletions
@@ -225,6 +225,10 @@
type="button"
class="main-topic-button"
[disabled]="!getMainTopicItem(item)?.id"
[matTooltip]="getTopicDescription(getMainTopicItem(item))"
[matTooltipDisabled]="
!hasTopicDescription(getMainTopicItem(item))
"
(click)="
selectTopic(getMainTopicItem(item), [item.year])
">
@@ -260,6 +264,8 @@
class="topic-chip"
[ngClass]="getColorClass(index)"
[disabled]="!topic.id"
[matTooltip]="getTopicDescription(topic)"
[matTooltipDisabled]="!hasTopicDescription(topic)"
(click)="selectTopic(topic, [item.year])">
<span class="topic-name">{{ topic.name }}</span>
<span class="topic-count">{{ topic.count }}</span>
@@ -322,6 +328,10 @@
type="button"
class="main-topic-button"
[disabled]="!phase.primaryTopic.id"
[matTooltip]="getTopicDescription(phase.primaryTopic)"
[matTooltipDisabled]="
!hasTopicDescription(phase.primaryTopic)
"
(click)="
selectTopic(phase.primaryTopic, getPhaseYears(phase))
">
@@ -340,6 +350,8 @@
class="topic-chip"
[ngClass]="getColorClass(index)"
[disabled]="!topic.id"
[matTooltip]="getTopicDescription(topic)"
[matTooltipDisabled]="!hasTopicDescription(topic)"
(click)="selectTopic(topic, getPhaseYears(phase))">
<span class="topic-name">{{ topic.name }}</span>
<span class="topic-count">{{ topic.count }}</span>
@@ -412,6 +424,8 @@
"
class="mini-topic-chip"
[disabled]="!topic.id"
[matTooltip]="getTopicDescription(topic)"
[matTooltipDisabled]="!hasTopicDescription(topic)"
(click)="selectTopic(topic, [year.year])">
<span>{{ topic.name }}</span>
<strong>{{ topic.count }}</strong>
@@ -17,6 +17,7 @@ export interface TopicTimelineTopic {
id?: string;
name: string;
count: number;
description?: string;
}
export interface TopicTimelineElement {
@@ -330,6 +331,14 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
);
}
getTopicDescription(topic: TopicTimelineTopic | undefined): string {
return (topic?.description ?? '').trim();
}
hasTopicDescription(topic: TopicTimelineTopic | undefined): boolean {
return this.getTopicDescription(topic).length > 0;
}
togglePhase(phase: ResearchTimelinePhase): void {
if (this.expandedPhaseIds.has(phase.id)) {
this.expandedPhaseIds.delete(phase.id);
@@ -608,6 +617,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
const primaryTopicName = primaryTopic.name;
let count = 0;
let id = primaryTopic.id;
let description = primaryTopic.description;
for (const year of years) {
for (const topic of year.primary_topics ?? []) {
@@ -620,6 +630,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
if (!id && topic.id) {
id = topic.id;
}
if (!description && topic.description) {
description = topic.description;
}
}
}
@@ -627,6 +641,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
id,
name: primaryTopicName,
count: count > 0 ? count : primaryTopic.count,
description,
};
}
@@ -637,6 +652,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
const counts = new Map<string, number>();
const originalNames = new Map<string, string>();
const ids = new Map<string, string>();
const descriptions = new Map<string, string>();
for (const year of years) {
for (const topic of year.topics ?? []) {
@@ -652,6 +668,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
ids.set(normalizedName, topic.id);
}
if (topic.description) {
descriptions.set(normalizedName, topic.description);
}
counts.set(
normalizedName,
(counts.get(normalizedName) ?? 0) + topic.count,
@@ -664,6 +684,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
id: ids.get(normalizedName),
name: originalNames.get(normalizedName) ?? normalizedName,
count,
description: descriptions.get(normalizedName),
}))
.sort((left, right) => {
if (right.count !== left.count) {
@@ -453,6 +453,7 @@ export class PersonOverviewComponent implements OnInit {
id: topic.id ?? undefined,
name: topic.name,
count: topic.count ?? 0,
description: topic.description ?? undefined,
}));
}