From 608c7cabe8ee22669cf62645226c0180c7b9230a Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Fri, 3 Nov 2023 16:26:27 +0000 Subject: [PATCH] switch tabs without navigation --- .../challenge/src/lib/challenge.component.html | 9 +++------ .../challenge/src/lib/challenge.component.ts | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libs/openchallenges/challenge/src/lib/challenge.component.html b/libs/openchallenges/challenge/src/lib/challenge.component.html index 043fd77304..9a132a051e 100644 --- a/libs/openchallenges/challenge/src/lib/challenge.component.html +++ b/libs/openchallenges/challenge/src/lib/challenge.component.html @@ -28,24 +28,21 @@

Overview Contributors Organizers diff --git a/libs/openchallenges/challenge/src/lib/challenge.component.ts b/libs/openchallenges/challenge/src/lib/challenge.component.ts index 94fddbd6e7..251dbba758 100644 --- a/libs/openchallenges/challenge/src/lib/challenge.component.ts +++ b/libs/openchallenges/challenge/src/lib/challenge.component.ts @@ -37,9 +37,10 @@ import { ChallengeOrganizersComponent } from './challenge-organizers/challenge-o import { ChallengeOverviewComponent } from './challenge-overview/challenge-overview.component'; import { ChallengeStargazersComponent } from './challenge-stargazers/challenge-stargazers.component'; import { ChallengeStatsComponent } from './challenge-stats/challenge-stats.component'; -import { CommonModule } from '@angular/common'; +import { CommonModule, Location } from '@angular/common'; import { SeoService } from '@sagebionetworks/shared/util'; import { getSeoData } from './challenge-seo-data'; +import { HttpParams } from '@angular/common/http'; @Component({ selector: 'openchallenges-challenge', @@ -83,7 +84,8 @@ export class ChallengeComponent implements OnInit { private challengeService: ChallengeService, private readonly configService: ConfigService, private seoService: SeoService, - private renderer2: Renderer2 + private renderer2: Renderer2, + private _location: Location ) { this.appVersion = this.configService.config.appVersion; this.dataUpdatedOn = this.configService.config.dataUpdatedOn; @@ -143,6 +145,16 @@ export class ChallengeComponent implements OnInit { this.subscriptions.push(activeTabSub); } + updateTab(activeTab: Tab) { + this.activeTab = activeTab; + const queryParams = { tab: activeTab.name }; + const newParam = new HttpParams({ + fromObject: queryParams, + }); + console.log(location.pathname); + this._location.replaceState(location.pathname, newParam.toString()); + } + // calcDays(startDate: string, endDate: string): number { // const timeDiff = +new Date(endDate) - +new Date(startDate); // return Math.round(timeDiff / (1000 * 60 * 60 * 24));