Timeline: add manual loading for earlier years
This commit is contained in:
+63
-4
@@ -6,6 +6,26 @@
|
||||
Entwicklung der Forschungsthemen im Zeitverlauf
|
||||
<span>(basierend auf Publikationen)</span>
|
||||
</p>
|
||||
|
||||
<button
|
||||
*ngIf="showEarlierYearsControl && timelineViewMode === 'compact' && !loading && !loadFailed"
|
||||
type="button"
|
||||
class="reset-range-button"
|
||||
[disabled]="loadingEarlierYears"
|
||||
(click)="requestEarlierYears()"
|
||||
>
|
||||
<span class="load-more-content">
|
||||
<mat-spinner *ngIf="loadingEarlierYears" diameter="16"></mat-spinner>
|
||||
<span>{{ earlierYearsLabel }}</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<span
|
||||
*ngIf="earlierYearsLoadFailed && timelineViewMode === 'compact' && !loadingEarlierYears"
|
||||
class="no-topics"
|
||||
>
|
||||
Frühere Jahre konnten nicht geladen werden.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="view-toggle" aria-label="Ansicht wechseln">
|
||||
@@ -81,8 +101,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="loading" class="timeline-state">
|
||||
Forschungstimeline wird geladen ...
|
||||
<div *ngIf="loading" class="timeline-state timeline-state-loading" aria-live="polite">
|
||||
<mat-spinner diameter="36"></mat-spinner>
|
||||
<span>Forschungstimeline wird geladen ...</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!loading && loadFailed" class="timeline-state timeline-state-error">
|
||||
@@ -92,11 +113,28 @@
|
||||
<ng-container *ngIf="!loading && !loadFailed">
|
||||
<ng-container *ngIf="timelineItems.length > 0; else emptyTimeline">
|
||||
<ng-container *ngIf="timelineViewMode === 'years'; else compactTimeline">
|
||||
<div class="timeline-wrapper">
|
||||
<div #timelineWrapper class="timeline-wrapper">
|
||||
<div class="timeline-inner" [style.min-width.px]="timelineMinWidth">
|
||||
<div class="timeline-axis" aria-hidden="true"></div>
|
||||
|
||||
<div class="timeline-points" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<div
|
||||
*ngIf="showEarlierYearsControl"
|
||||
class="timeline-point"
|
||||
[ngClass]="getColorClass(0)"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="year-button"
|
||||
[disabled]="loadingEarlierYears"
|
||||
(click)="requestEarlierYears()"
|
||||
aria-label="Frühere Jahre der Forschungstimeline laden"
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
<span class="dot"></span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-point"
|
||||
@@ -115,9 +153,30 @@
|
||||
</div>
|
||||
|
||||
<div class="timeline-content" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<article *ngIf="showEarlierYearsControl" class="timeline-item">
|
||||
<h3>
|
||||
<button
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="loadingEarlierYears"
|
||||
(click)="requestEarlierYears()"
|
||||
>
|
||||
<span class="load-more-content">
|
||||
<mat-spinner *ngIf="loadingEarlierYears" diameter="18"></mat-spinner>
|
||||
<span>{{ earlierYearsLabel }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</h3>
|
||||
|
||||
<span *ngIf="earlierYearsLoadFailed && !loadingEarlierYears" class="no-topics">
|
||||
Laden fehlgeschlagen.
|
||||
</span>
|
||||
</article>
|
||||
|
||||
<article
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-item"
|
||||
[attr.data-timeline-year]="item.year"
|
||||
>
|
||||
<h3>
|
||||
<button
|
||||
@@ -311,4 +370,4 @@
|
||||
Keine Timeline-Daten vorhanden.
|
||||
</div>
|
||||
</ng-template>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
+22
@@ -637,6 +637,23 @@
|
||||
background: #52627f;
|
||||
}
|
||||
|
||||
.load-more-content {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.timeline-title .reset-range-button {
|
||||
display: inline-flex;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.timeline-title > .no-topics {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.timeline-state {
|
||||
display: flex;
|
||||
min-height: 140px;
|
||||
@@ -648,6 +665,11 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.timeline-state-loading {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.timeline-state-error {
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
+173
-4
@@ -1,11 +1,15 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import {
|
||||
AfterViewChecked,
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnChanges,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
|
||||
export interface TopicTimelineTopic {
|
||||
@@ -53,17 +57,28 @@ interface WorkingResearchTimelinePhase {
|
||||
years: TopicTimelineElement[];
|
||||
}
|
||||
|
||||
interface TimelineScrollAnchor {
|
||||
year: number;
|
||||
offsetLeft: number;
|
||||
scrollLeft: number;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-research-timeline',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
imports: [CommonModule, MatProgressSpinnerModule],
|
||||
templateUrl: './research-timeline.component.html',
|
||||
styleUrl: './research-timeline.component.scss',
|
||||
})
|
||||
export class ResearchTimelineComponent implements OnChanges {
|
||||
export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
@ViewChild('timelineWrapper')
|
||||
private timelineWrapper?: ElementRef<HTMLDivElement>;
|
||||
@Input() elements: TopicTimelineElement[] = [];
|
||||
@Input() loading = false;
|
||||
@Input() loadFailed = false;
|
||||
@Input() canLoadEarlierYears = false;
|
||||
@Input() loadingEarlierYears = false;
|
||||
@Input() earlierYearsLoadFailed = false;
|
||||
@Input() viewMode: TimelineViewMode = 'years';
|
||||
@Input() startYear: number | undefined;
|
||||
@Input() endYear: number | undefined;
|
||||
@@ -72,6 +87,7 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
|
||||
@Output() topicSelect = new EventEmitter<TimelineTopicSelection>();
|
||||
@Output() yearSelect = new EventEmitter<number[]>();
|
||||
@Output() loadEarlierYears = new EventEmitter<void>();
|
||||
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
|
||||
@@ -84,9 +100,16 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
private readonly columnWidth = 240;
|
||||
private readonly displayedTopicLimit = 3;
|
||||
private readonly displayedPhaseTopicLimit = 4;
|
||||
private readonly scrollRestoreThreshold = 24;
|
||||
private readonly expandedPhaseIds = new Set<string>();
|
||||
|
||||
private pendingTimelineScrollAnchor: TimelineScrollAnchor | undefined;
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['elements']) {
|
||||
this.captureTimelineScrollAnchor();
|
||||
}
|
||||
|
||||
if (changes['viewMode']) {
|
||||
this.timelineViewMode = this.isTimelineViewMode(this.viewMode)
|
||||
? this.viewMode
|
||||
@@ -102,6 +125,22 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
if (!this.pendingTimelineScrollAnchor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollAnchor = this.pendingTimelineScrollAnchor;
|
||||
this.pendingTimelineScrollAnchor = undefined;
|
||||
|
||||
if (typeof requestAnimationFrame === 'function') {
|
||||
requestAnimationFrame(() => this.restoreTimelineScrollAnchor(scrollAnchor));
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => this.restoreTimelineScrollAnchor(scrollAnchor));
|
||||
}
|
||||
|
||||
get timelineItems(): TopicTimelineElement[] {
|
||||
return this.sortedElements.filter((item) => {
|
||||
return item.year >= this.selectedStartYear && item.year <= this.selectedEndYear;
|
||||
@@ -120,6 +159,22 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
return this.selectedStartYear !== this.minYear || this.selectedEndYear !== this.maxYear;
|
||||
}
|
||||
|
||||
get showEarlierYearsControl(): boolean {
|
||||
return this.canLoadEarlierYears || this.loadingEarlierYears;
|
||||
}
|
||||
|
||||
get earlierYearsLabel(): string {
|
||||
if (this.loadingEarlierYears) {
|
||||
return 'Frühere Jahre werden geladen ...';
|
||||
}
|
||||
|
||||
if (this.earlierYearsLoadFailed) {
|
||||
return 'Frühere Jahre erneut laden';
|
||||
}
|
||||
|
||||
return 'Frühere Jahre anzeigen';
|
||||
}
|
||||
|
||||
get rangeStartPercent(): string {
|
||||
return `${this.calculateRangePercent(this.selectedStartYear)}%`;
|
||||
}
|
||||
@@ -129,15 +184,31 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
}
|
||||
|
||||
get gridTemplateColumns(): string {
|
||||
const count = Math.max(this.timelineItems.length, 1);
|
||||
const count = Math.max(
|
||||
this.timelineItems.length + this.earlierYearsColumnCount,
|
||||
1,
|
||||
);
|
||||
|
||||
return `repeat(${count}, minmax(${this.columnWidth}px, 1fr))`;
|
||||
}
|
||||
|
||||
get timelineMinWidth(): number {
|
||||
const count = Math.max(this.timelineItems.length, 1);
|
||||
const count = Math.max(
|
||||
this.timelineItems.length + this.earlierYearsColumnCount,
|
||||
1,
|
||||
);
|
||||
|
||||
return Math.max(count * this.columnWidth, 1000);
|
||||
}
|
||||
|
||||
requestEarlierYears(): void {
|
||||
if (!this.canLoadEarlierYears || this.loadingEarlierYears) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadEarlierYears.emit();
|
||||
}
|
||||
|
||||
setTimelineViewMode(mode: TimelineViewMode): void {
|
||||
if (this.timelineViewMode === mode) {
|
||||
return;
|
||||
@@ -266,6 +337,104 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
return phase.id;
|
||||
}
|
||||
|
||||
|
||||
private captureTimelineScrollAnchor(): void {
|
||||
if (this.timelineViewMode !== 'years') {
|
||||
return;
|
||||
}
|
||||
|
||||
const wrapper = this.timelineWrapper?.nativeElement;
|
||||
|
||||
if (!wrapper || wrapper.scrollLeft <= this.scrollRestoreThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollAnchor = this.findVisibleTimelineAnchor(wrapper);
|
||||
|
||||
if (!scrollAnchor) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pendingTimelineScrollAnchor = scrollAnchor;
|
||||
}
|
||||
|
||||
private restoreTimelineScrollAnchor(scrollAnchor: TimelineScrollAnchor): void {
|
||||
if (this.timelineViewMode !== 'years') {
|
||||
return;
|
||||
}
|
||||
|
||||
const wrapper = this.timelineWrapper?.nativeElement;
|
||||
|
||||
if (!wrapper) {
|
||||
return;
|
||||
}
|
||||
|
||||
const anchorElement = wrapper.querySelector<HTMLElement>(
|
||||
`.timeline-content .timeline-item[data-timeline-year="${scrollAnchor.year}"]`,
|
||||
);
|
||||
|
||||
if (!anchorElement) {
|
||||
wrapper.scrollLeft = scrollAnchor.scrollLeft;
|
||||
return;
|
||||
}
|
||||
|
||||
const wrapperRect = wrapper.getBoundingClientRect();
|
||||
const anchorRect = anchorElement.getBoundingClientRect();
|
||||
const nextOffsetLeft = anchorRect.left - wrapperRect.left;
|
||||
|
||||
wrapper.scrollLeft += nextOffsetLeft - scrollAnchor.offsetLeft;
|
||||
}
|
||||
|
||||
private findVisibleTimelineAnchor(
|
||||
wrapper: HTMLDivElement,
|
||||
): TimelineScrollAnchor | undefined {
|
||||
const wrapperRect = wrapper.getBoundingClientRect();
|
||||
const yearElements = Array.from(
|
||||
wrapper.querySelectorAll<HTMLElement>(
|
||||
'.timeline-content .timeline-item[data-timeline-year]',
|
||||
),
|
||||
);
|
||||
|
||||
let bestAnchor: TimelineScrollAnchor | undefined;
|
||||
let bestDistance = Number.POSITIVE_INFINITY;
|
||||
|
||||
for (const element of yearElements) {
|
||||
const year = Number(element.dataset['timelineYear']);
|
||||
|
||||
if (!Number.isFinite(year)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const elementRect = element.getBoundingClientRect();
|
||||
const isVisible =
|
||||
elementRect.right > wrapperRect.left && elementRect.left < wrapperRect.right;
|
||||
|
||||
if (!isVisible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const offsetLeft = elementRect.left - wrapperRect.left;
|
||||
const distanceFromLeftEdge = Math.abs(offsetLeft);
|
||||
|
||||
if (distanceFromLeftEdge >= bestDistance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bestDistance = distanceFromLeftEdge;
|
||||
bestAnchor = {
|
||||
year,
|
||||
offsetLeft,
|
||||
scrollLeft: wrapper.scrollLeft,
|
||||
};
|
||||
}
|
||||
|
||||
return bestAnchor;
|
||||
}
|
||||
|
||||
private get earlierYearsColumnCount(): number {
|
||||
return this.showEarlierYearsControl ? 1 : 0;
|
||||
}
|
||||
|
||||
private get sortedElements(): TopicTimelineElement[] {
|
||||
return [...(this.elements ?? [])].sort((left, right) => left.year - right.year);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
[elements]="topicTimelineElements"
|
||||
[loading]="loadingTimeline"
|
||||
[loadFailed]="timelineLoadFailed"
|
||||
[canLoadEarlierYears]="timelineCanLoadEarlierYears"
|
||||
[loadingEarlierYears]="timelineLoadingEarlierYears"
|
||||
[earlierYearsLoadFailed]="timelineEarlierYearsLoadFailed"
|
||||
[viewMode]="timelineViewMode"
|
||||
[startYear]="timelineStartYear"
|
||||
[endYear]="timelineEndYear"
|
||||
@@ -10,5 +13,6 @@
|
||||
(yearRangeChange)="onTimelineYearRangeChange($event)"
|
||||
(topicSelect)="onTimelineTopicSelect($event)"
|
||||
(yearSelect)="onTimelineYearSelect($event)"
|
||||
(loadEarlierYears)="onTimelineLoadEarlierYears()"
|
||||
></app-research-timeline>
|
||||
</section>
|
||||
</section>
|
||||
@@ -4,7 +4,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
|
||||
|
||||
import { TopicCount,TopicsByYear } from '../../api';
|
||||
import { TopicCount, TopicsByYear } from '../../api';
|
||||
import { WorksService } from '../../api';
|
||||
import {
|
||||
ResearchTimelineComponent,
|
||||
@@ -26,15 +26,23 @@ export class PersonOverviewComponent implements OnInit {
|
||||
private static readonly timelineViewQueryParam = 'timeline_view';
|
||||
private static readonly timelineStartYearQueryParam = 'timeline_start_year';
|
||||
private static readonly timelineEndYearQueryParam = 'timeline_end_year';
|
||||
private static readonly timelineTopicCountLimit = 4;
|
||||
private static readonly initialTimelineTargetPublications = 300;
|
||||
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly worksService = inject(WorksService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
private currentAuthorId = '';
|
||||
private timelineLoadId = 0;
|
||||
|
||||
topicTimelineElements: TopicTimelineElement[] = [];
|
||||
loadingTimeline = false;
|
||||
timelineLoadFailed = false;
|
||||
timelineCanLoadEarlierYears = false;
|
||||
timelineLoadingEarlierYears = false;
|
||||
timelineEarlierYearsLoadFailed = false;
|
||||
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
timelineStartYear: number | undefined;
|
||||
@@ -120,6 +128,19 @@ export class PersonOverviewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onTimelineLoadEarlierYears(): void {
|
||||
if (
|
||||
!this.currentAuthorId ||
|
||||
this.currentAuthorId === '0' ||
|
||||
this.timelineLoadingEarlierYears ||
|
||||
!this.timelineCanLoadEarlierYears
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadCompleteTopicTimeline(this.currentAuthorId);
|
||||
}
|
||||
|
||||
private findAuthorId(paramMaps: readonly ParamMap[]): string {
|
||||
return (
|
||||
paramMaps
|
||||
@@ -129,36 +150,112 @@ export class PersonOverviewComponent implements OnInit {
|
||||
}
|
||||
|
||||
private loadTopicTimeline(authorId: string): void {
|
||||
const loadId = ++this.timelineLoadId;
|
||||
this.currentAuthorId = authorId;
|
||||
|
||||
if (!authorId || authorId === '0') {
|
||||
this.topicTimelineElements = [];
|
||||
this.loadingTimeline = false;
|
||||
this.timelineLoadFailed = false;
|
||||
this.resetTimelineState();
|
||||
return;
|
||||
}
|
||||
|
||||
this.topicTimelineElements = [];
|
||||
this.loadingTimeline = true;
|
||||
this.timelineLoadFailed = false;
|
||||
|
||||
const topicCountLimit = 4;
|
||||
this.timelineCanLoadEarlierYears = false;
|
||||
this.timelineLoadingEarlierYears = false;
|
||||
this.timelineEarlierYearsLoadFailed = false;
|
||||
|
||||
this.worksService
|
||||
.getTopicsByTimeByAuthor(authorId, topicCountLimit)
|
||||
.getTopicsByTimeByAuthor(
|
||||
authorId,
|
||||
PersonOverviewComponent.timelineTopicCountLimit,
|
||||
PersonOverviewComponent.initialTimelineTargetPublications,
|
||||
false,
|
||||
)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
this.topicTimelineElements = this.mapTimelineElements(response.elements);
|
||||
if (!this.isCurrentTimelineLoad(loadId, authorId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timelineElements = this.mapTimelineElements(response.elements);
|
||||
|
||||
this.topicTimelineElements = timelineElements;
|
||||
this.loadingTimeline = false;
|
||||
this.timelineLoadFailed = false;
|
||||
this.timelineCanLoadEarlierYears =
|
||||
this.getTimelinePublicationCount(timelineElements) >=
|
||||
PersonOverviewComponent.initialTimelineTargetPublications;
|
||||
},
|
||||
error: (error) => {
|
||||
if (!this.isCurrentTimelineLoad(loadId, authorId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('Topic timeline could not be loaded.', error);
|
||||
this.topicTimelineElements = [];
|
||||
this.loadingTimeline = false;
|
||||
this.timelineLoadFailed = true;
|
||||
this.timelineCanLoadEarlierYears = false;
|
||||
this.timelineLoadingEarlierYears = false;
|
||||
this.timelineEarlierYearsLoadFailed = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private loadCompleteTopicTimeline(authorId: string): void {
|
||||
const loadId = this.timelineLoadId;
|
||||
|
||||
this.timelineLoadingEarlierYears = true;
|
||||
this.timelineEarlierYearsLoadFailed = false;
|
||||
|
||||
this.worksService
|
||||
.getTopicsByTimeByAuthor(
|
||||
authorId,
|
||||
PersonOverviewComponent.timelineTopicCountLimit,
|
||||
undefined,
|
||||
true,
|
||||
)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
if (!this.isCurrentTimelineLoad(loadId, authorId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const completeTimelineElements = this.mapTimelineElements(response.elements);
|
||||
|
||||
this.topicTimelineElements = this.mergeTimelineElements(
|
||||
this.topicTimelineElements,
|
||||
completeTimelineElements,
|
||||
);
|
||||
this.timelineCanLoadEarlierYears = false;
|
||||
this.timelineLoadingEarlierYears = false;
|
||||
this.timelineEarlierYearsLoadFailed = false;
|
||||
},
|
||||
error: (error) => {
|
||||
if (!this.isCurrentTimelineLoad(loadId, authorId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('Complete topic timeline could not be loaded.', error);
|
||||
this.timelineCanLoadEarlierYears = true;
|
||||
this.timelineLoadingEarlierYears = false;
|
||||
this.timelineEarlierYearsLoadFailed = true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private resetTimelineState(): void {
|
||||
this.topicTimelineElements = [];
|
||||
this.loadingTimeline = false;
|
||||
this.timelineLoadFailed = false;
|
||||
this.timelineCanLoadEarlierYears = false;
|
||||
this.timelineLoadingEarlierYears = false;
|
||||
this.timelineEarlierYearsLoadFailed = false;
|
||||
}
|
||||
|
||||
private mapTimelineElements(
|
||||
elements: TopicsByYear[] | undefined,
|
||||
): TopicTimelineElement[] {
|
||||
@@ -178,6 +275,31 @@ export class PersonOverviewComponent implements OnInit {
|
||||
}));
|
||||
}
|
||||
|
||||
private mergeTimelineElements(
|
||||
currentElements: TopicTimelineElement[],
|
||||
completeElements: TopicTimelineElement[],
|
||||
): TopicTimelineElement[] {
|
||||
const elementsByYear = new Map<number, TopicTimelineElement>();
|
||||
|
||||
for (const element of currentElements) {
|
||||
elementsByYear.set(element.year, element);
|
||||
}
|
||||
|
||||
for (const element of completeElements) {
|
||||
elementsByYear.set(element.year, element);
|
||||
}
|
||||
|
||||
return [...elementsByYear.values()].sort((left, right) => left.year - right.year);
|
||||
}
|
||||
|
||||
private getTimelinePublicationCount(elements: TopicTimelineElement[]): number {
|
||||
return elements.reduce((total, element) => total + element.publication_count, 0);
|
||||
}
|
||||
|
||||
private isCurrentTimelineLoad(loadId: number, authorId: string): boolean {
|
||||
return loadId === this.timelineLoadId && authorId === this.currentAuthorId;
|
||||
}
|
||||
|
||||
private parseTimelineViewMode(value: string | null): TimelineViewMode {
|
||||
return value === 'compact' ? 'compact' : 'years';
|
||||
}
|
||||
@@ -207,4 +329,4 @@ export class PersonOverviewComponent implements OnInit {
|
||||
replaceUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user