Add institution tab navigation
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {
|
||||
AfterViewInit,
|
||||
Component,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -78,7 +85,10 @@ type DashboardPeriodMode =
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrl: './dashboard.component.scss',
|
||||
})
|
||||
export class DashboardComponent implements OnInit {
|
||||
export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('analyticalInstitutionTabList')
|
||||
private analyticalInstitutionTabList?: ElementRef<HTMLElement>;
|
||||
|
||||
readonly AuthorTooltipComponent = AppAuthorTooltipComponent;
|
||||
readonly patentIcon = PATENT_ICON;
|
||||
statistics?: Partial<DashboardStatistics>;
|
||||
@@ -139,6 +149,8 @@ export class DashboardComponent implements OnInit {
|
||||
selectedAnalyticalInstitutionId = this.defaultAnalyticalInstitutionId;
|
||||
dashboardInstitutionsLoading = false;
|
||||
dashboardInstitutionsError = false;
|
||||
canScrollAnalyticalInstitutionTabsLeft = false;
|
||||
canScrollAnalyticalInstitutionTabsRight = false;
|
||||
selectedTopicTreemapNode?: string;
|
||||
selectedDfgTopicTreemapNode?: string;
|
||||
selectedEuTopicTreemapNode?: string;
|
||||
@@ -168,6 +180,15 @@ export class DashboardComponent implements OnInit {
|
||||
this.loadDfgProjectStatuses();
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
setTimeout(() => this.updateAnalyticalInstitutionTabScrollState());
|
||||
}
|
||||
|
||||
@HostListener('window:resize')
|
||||
onWindowResize(): void {
|
||||
this.updateAnalyticalInstitutionTabScrollState();
|
||||
}
|
||||
|
||||
private loadDashboardInstitutions(): void {
|
||||
this.dashboardInstitutionsLoading = true;
|
||||
this.dashboardInstitutionsError = false;
|
||||
@@ -177,6 +198,7 @@ export class DashboardComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (institutions) => {
|
||||
this.dashboardInstitutions = institutions;
|
||||
setTimeout(() => this.updateAnalyticalInstitutionTabScrollState());
|
||||
const requestedInstitution =
|
||||
this.route.snapshot.queryParamMap.get('institution') ?? 'all';
|
||||
const restoredInstitution = institutions.some(
|
||||
@@ -451,6 +473,30 @@ export class DashboardComponent implements OnInit {
|
||||
this.reloadAnalyticalData();
|
||||
}
|
||||
|
||||
scrollAnalyticalInstitutionTabs(direction: -1 | 1): void {
|
||||
const tabList = this.analyticalInstitutionTabList?.nativeElement;
|
||||
if (!tabList) return;
|
||||
|
||||
tabList.scrollBy({
|
||||
left: direction * Math.floor(tabList.clientWidth * 0.75),
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
|
||||
updateAnalyticalInstitutionTabScrollState(): void {
|
||||
const tabList = this.analyticalInstitutionTabList?.nativeElement;
|
||||
if (!tabList) {
|
||||
this.canScrollAnalyticalInstitutionTabsLeft = false;
|
||||
this.canScrollAnalyticalInstitutionTabsRight = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const maxScrollLeft = tabList.scrollWidth - tabList.clientWidth;
|
||||
this.canScrollAnalyticalInstitutionTabsLeft = tabList.scrollLeft > 1;
|
||||
this.canScrollAnalyticalInstitutionTabsRight =
|
||||
tabList.scrollLeft < maxScrollLeft - 1;
|
||||
}
|
||||
|
||||
onTopicTreemapNodeChange(nodeId: string | undefined): void {
|
||||
this.selectedTopicTreemapNode = nodeId;
|
||||
this.updateDashboardPeriodUrl();
|
||||
|
||||
Reference in New Issue
Block a user