Skip to content

Commit

Permalink
cwdoe-1388-honor-url-section
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-tspencer committed Jun 5, 2024
1 parent 48e05f1 commit c095f97
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cite-ui",
"version": "1.6.2",
"version": "1.6.3",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export class EvaluationInfoComponent implements OnDestroy {
@Input() moveList: Move[];
@Input() scoresheetOnRight: boolean;
@Input() noChanges: boolean;
@Input() selectedSection: Section;
@Output() nextDisplayedMove = new EventEmitter<Move>();
@Output() previousDisplayedMove = new EventEmitter<Move>();
@Output() nextEvaluationMove = new EventEmitter<number>();
@Output() changeTeam = new EventEmitter<string>();
@Output() changeSection = new EventEmitter<string>();
@Output() changeEvaluation = new EventEmitter<string>();
selectedEvaluationId = '';
selectedSection = Section.dashboard;
dashboardSection = Section.dashboard;
scoresheetSection = Section.scoresheet;
reportSection = Section.report;
Expand Down Expand Up @@ -73,7 +73,6 @@ export class EvaluationInfoComponent implements OnDestroy {
(this.teamQuery.selectActive() as Observable<Team>).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
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/app/components/home-app/home-app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ <h2>Please contact the site administrator or your event facilator.</h2>
[moveList]="moveList$ | async"
[scoresheetOnRight]="(activeScoringModel$ | async)?.rightSideDisplay === 'Scoresheet'"
[noChanges]="noChanges$ | async"
[selectedSection]="selectedSection"
(nextDisplayedMove)="nextDisplayedMove($event)"
(previousDisplayedMove)="previousDisplayedMove($event)"
(nextEvaluationMove)="nextEvaluationMove($event)"
Expand Down
18 changes: 16 additions & 2 deletions src/app/components/home-app/home-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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 => {
Expand Down

0 comments on commit c095f97

Please sign in to comment.