From c095f97995eedf67a951e97eca011afa64a42f12 Mon Sep 17 00:00:00 2001 From: sei-tspencer Date: Wed, 5 Jun 2024 15:39:14 -0400 Subject: [PATCH] cwdoe-1388-honor-url-section --- package.json | 2 +- .../evaluation-info.component.ts | 4 +--- .../home-app/home-app.component.html | 1 + .../components/home-app/home-app.component.ts | 18 ++++++++++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 9fb1ed9..49e0961 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cite-ui", - "version": "1.6.2", + "version": "1.6.3", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/src/app/components/evaluation-info/evaluation-info.component.ts b/src/app/components/evaluation-info/evaluation-info.component.ts index a428474..7797639 100755 --- a/src/app/components/evaluation-info/evaluation-info.component.ts +++ b/src/app/components/evaluation-info/evaluation-info.component.ts @@ -30,6 +30,7 @@ export class EvaluationInfoComponent implements OnDestroy { @Input() moveList: Move[]; @Input() scoresheetOnRight: boolean; @Input() noChanges: boolean; + @Input() selectedSection: Section; @Output() nextDisplayedMove = new EventEmitter(); @Output() previousDisplayedMove = new EventEmitter(); @Output() nextEvaluationMove = new EventEmitter(); @@ -37,7 +38,6 @@ export class EvaluationInfoComponent implements OnDestroy { @Output() changeSection = new EventEmitter(); @Output() changeEvaluation = new EventEmitter(); selectedEvaluationId = ''; - selectedSection = Section.dashboard; dashboardSection = Section.dashboard; scoresheetSection = Section.scoresheet; reportSection = Section.report; @@ -73,7 +73,6 @@ export class EvaluationInfoComponent implements OnDestroy { (this.teamQuery.selectActive() as Observable).pipe(takeUntil(this.unsubscribe$)).subscribe(t => { if (t) { this.selectedTeamId = t ? t.id : this.selectedTeamId; - this.setSection(this.selectedSection); } }); // observe the team users to get permissions @@ -82,7 +81,6 @@ export class EvaluationInfoComponent implements OnDestroy { const currentTeamUser = teamUsers.find(tu => tu.userId === userId); this.canIncrementMove = currentTeamUser ? currentTeamUser.canIncrementMove : false; }); - this.setSection(this.uiDataService.getSection(this.selectedEvaluationId) as Section); this.selectedTeamId = this.uiDataService.getTeam(this.selectedEvaluationId); } diff --git a/src/app/components/home-app/home-app.component.html b/src/app/components/home-app/home-app.component.html index 940d6b0..4030e1e 100755 --- a/src/app/components/home-app/home-app.component.html +++ b/src/app/components/home-app/home-app.component.html @@ -61,6 +61,7 @@

Please contact the site administrator or your event facilator.

[moveList]="moveList$ | async" [scoresheetOnRight]="(activeScoringModel$ | async)?.rightSideDisplay === 'Scoresheet'" [noChanges]="noChanges$ | async" + [selectedSection]="selectedSection" (nextDisplayedMove)="nextDisplayedMove($event)" (previousDisplayedMove)="previousDisplayedMove($event)" (nextEvaluationMove)="nextEvaluationMove($event)" diff --git a/src/app/components/home-app/home-app.component.ts b/src/app/components/home-app/home-app.component.ts index 410ccea..3264162 100755 --- a/src/app/components/home-app/home-app.component.ts +++ b/src/app/components/home-app/home-app.component.ts @@ -219,21 +219,36 @@ export class HomeAppComponent implements OnDestroy, OnInit { this.userDataService.getUsersFromApi(); // observe route changes activatedRoute.queryParamMap.pipe(takeUntil(this.unsubscribe$)).subscribe(params => { + // get and set the evaluation const evaluationId = params.get('evaluation'); if (evaluationId) { this.evaluationDataService.setActive(evaluationId); this.uiDataService.setEvaluation(evaluationId); } + // get the requested section or set the saved section const section = params.get('section'); switch (section) { case 'scoresheet': + // set scoresheet this.selectedSection = Section.scoresheet; + this.uiDataService.setSection(evaluationId, Section.scoresheet); + // now remove the section from the url, so that refreshes work properly + this.router.navigate([], { + queryParams: { evaluation: evaluationId }, + }); break; case 'dashboard': + // set dashboard this.selectedSection = Section.dashboard; + this.uiDataService.setSection(evaluationId, Section.dashboard); + // now remove the section from the url, so that refreshes work properly + this.router.navigate([], { + queryParams: { evaluation: evaluationId }, + }); break; default: - const savedSection = this.uiDataService.getSection(this.selectedEvaluationId); + // get the saved section + const savedSection = this.uiDataService.getSection(evaluationId); if (savedSection === 'scoresheet') { this.selectedSection = Section.scoresheet; } else if (savedSection === 'report') { @@ -243,7 +258,6 @@ export class HomeAppComponent implements OnDestroy, OnInit { } break; } - this.uiDataService.setSection(this.selectedEvaluationId, this.selectedSection); }); // observe the submissions this.submissionList$.pipe(takeUntil(this.unsubscribe$)).subscribe(submissions => {