Fix timeline topic year selection
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
+6
-6
@@ -117,7 +117,7 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!getMainTopicItem(item)?.id"
|
||||
(click)="selectTopic(getMainTopicItem(item)!)"
|
||||
(click)="selectTopic(getMainTopicItem(item), [item.year])"
|
||||
>
|
||||
{{ getMainTopic(item) }}
|
||||
</button>
|
||||
@@ -136,7 +136,7 @@
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic)"
|
||||
(click)="selectTopic(topic, [item.year])"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
@@ -172,7 +172,7 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!phase.primaryTopic.id"
|
||||
(click)="selectTopic(phase.primaryTopic)"
|
||||
(click)="selectTopic(phase.primaryTopic, getPhaseYears(phase))"
|
||||
>
|
||||
{{ phase.primaryTopicName }}
|
||||
</button>
|
||||
@@ -192,7 +192,7 @@
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic)"
|
||||
(click)="selectTopic(topic, getPhaseYears(phase))"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
@@ -240,7 +240,7 @@
|
||||
"
|
||||
class="mini-topic-chip"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic)"
|
||||
(click)="selectTopic(topic, [year.year])"
|
||||
>
|
||||
<span>{{ topic.name }}</span>
|
||||
<strong>{{ topic.count }}</strong>
|
||||
@@ -273,4 +273,4 @@
|
||||
Keine Timeline-Daten vorhanden.
|
||||
</div>
|
||||
</ng-template>
|
||||
</section>
|
||||
</section>
|
||||
+12
-9
@@ -176,14 +176,14 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
this.emitYearRangeChange();
|
||||
}
|
||||
|
||||
selectTopic(topic: TopicTimelineTopic): void {
|
||||
if (!topic.id) {
|
||||
selectTopic(topic: TopicTimelineTopic | undefined, years: number[]): void {
|
||||
if (!topic?.id || years.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.topicSelect.emit({
|
||||
topic,
|
||||
years: this.createSelectedYears(),
|
||||
years: this.normalizeSelectedYears(years),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,6 +222,10 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
return `${phase.startYear}–${phase.endYear}`;
|
||||
}
|
||||
|
||||
getPhaseYears(phase: ResearchTimelinePhase): number[] {
|
||||
return phase.years.map((year) => year.year);
|
||||
}
|
||||
|
||||
togglePhase(phase: ResearchTimelinePhase): void {
|
||||
if (this.expandedPhaseIds.has(phase.id)) {
|
||||
this.expandedPhaseIds.delete(phase.id);
|
||||
@@ -405,11 +409,10 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
.slice(0, this.displayedPhaseTopicLimit);
|
||||
}
|
||||
|
||||
private createSelectedYears(): number[] {
|
||||
return Array.from(
|
||||
{ length: this.selectedEndYear - this.selectedStartYear + 1 },
|
||||
(_, index) => this.selectedStartYear + index,
|
||||
);
|
||||
private normalizeSelectedYears(years: number[]): number[] {
|
||||
return Array.from(new Set(years))
|
||||
.filter((year) => Number.isFinite(year))
|
||||
.sort((left, right) => left - right);
|
||||
}
|
||||
|
||||
private getDominantPrimaryTopicCandidates(item: TopicTimelineElement): TopicTimelineTopic[] {
|
||||
@@ -483,4 +486,4 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
endYear: this.selectedEndYear,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user