Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/337 dossier tabs #399

Merged
merged 6 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
>
<a
class="student"
[routerLink]="['student', entry.lessonPresence.StudentRef.Id]"
[routerLink]="[
'student',
entry.lessonPresence.StudentRef.Id,
'absences'
]"
[queryParams]="{ returnparams: profileReturnParams$ | async }"
>
{{ entry.lessonPresence.StudentFullName }}
Expand Down
4 changes: 3 additions & 1 deletion src/app/edit-absences/edit-absences-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const routes: Routes = [
data: {
restoreScrollPositionFrom: [
'/edit-absences/edit',
'/edit-absences/student/:id',
'/edit-absences/student/:id/addresses',
'/edit-absences/student/:id/absences',
'/edit-absences/student/:id/grades',
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<a
*ngIf="column.key === 'StudentFullName'; else noLink"
class="student"
[routerLink]="['student', entry.StudentRef.Id]"
[routerLink]="['student', entry.StudentRef.Id, 'absences']"
[queryParams]="{ returnparams: profileReturnParams$ | async }"
>
{{ entry[column.key] }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"
>
<td class="primary-column-width sticky">
<a [routerLink]="['student', studentGrade.student.Id]">
<a [routerLink]="['student', studentGrade.student.Id, 'grades']">
<span class="text-body text-truncate">{{
studentGrade.student.FullName
}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<i class="material-icons-outlined">info</i>
</button>
<a
[routerLink]="['student', entry.lessonPresence.StudentRef.Id]"
[routerLink]="['student', entry.lessonPresence.StudentRef.Id, 'absences']"
[queryParams]="profileReturnParams"
class="student-name"
>
Expand Down
6 changes: 5 additions & 1 deletion src/app/presence-control/presence-control-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const routes: Routes = [
path: '',
component: PresenceControlListComponent,
data: {
restoreScrollPositionFrom: ['/presence-control/student/:id'],
restoreScrollPositionFrom: [
'/presence-control/student/:id/addresses',
'/presence-control/student/:id/absences',
'/presence-control/student/:id/grades',
],
},
},
dossierRoute,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BehaviorSubject, of } from 'rxjs';
import { of } from 'rxjs';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { DossierStateService } from '../../../services/dossier-state.service';
import { StudentProfileAbsencesService } from '../../../services/student-profile-absences.service';
Expand All @@ -10,11 +10,8 @@ import { DossierAbsencesComponent } from './dossier-absences.component';
describe('DossierAbsencesComponent', () => {
let component: DossierAbsencesComponent;
let fixture: ComponentFixture<DossierAbsencesComponent>;
let isOverview$: BehaviorSubject<boolean>;

beforeEach(async () => {
isOverview$ = new BehaviorSubject<boolean>(false);

await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class DossierAbsencesComponent implements OnInit, OnDestroy {
public absencesService: StudentProfileAbsencesService,
public absencesSelectionService: ConfirmAbsencesSelectionService
) {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('absences');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ describe('DossierAddressesComponent', () => {
let component: DossierAddressesComponent;
let fixture: ComponentFixture<DossierAddressesComponent>;
let stateServiceMock: DossierStateService;
let isOverview$: BehaviorSubject<boolean>;
let currentDossier$: BehaviorSubject<DossierPage>;

beforeEach(async () => {
isOverview$ = new BehaviorSubject<boolean>(false);
currentDossier$ = new BehaviorSubject<DossierPage>('addresses');

stateServiceMock = ({
Expand All @@ -29,7 +27,6 @@ describe('DossierAddressesComponent', () => {
legalRepresentativePersons: [],
apprenticeshipCompanies: [],
}),
isOverview$,
currentDossier$,
} as unknown) as DossierStateService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { DossierStateService } from 'src/app/shared/services/dossier-state.servi
})
export class DossierAddressesComponent {
constructor(public state: DossierStateService) {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('addresses');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('DossierGradesComponent', () => {
let fixture: ComponentFixture<DossierGradesComponent>;

let dossierStateServiceMock: DossierStateService;
let isOverview$: BehaviorSubject<boolean>;
let currentDossier$: BehaviorSubject<DossierPage>;

let dossierGradesServiceMock: DossierGradesService;
Expand All @@ -30,11 +29,9 @@ describe('DossierGradesComponent', () => {
const gradingScales = [buildGradingScale(1)];

beforeEach(async () => {
isOverview$ = new BehaviorSubject<boolean>(false);
currentDossier$ = new BehaviorSubject<DossierPage>('grades');

dossierStateServiceMock = ({
isOverview$,
currentDossier$,
studentId$: of(123),
} as unknown) as DossierStateService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class DossierGradesComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();

ngOnInit(): void {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('grades');

this.state.studentId$
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/shared/components/student-dossier/dossier-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ConfirmAbsencesComponent } from '../confirm-absences/confirm-absences.c
import { StudentDossierComponent } from './student-dossier/student-dossier.component';
import { DossierAbsencesComponent } from './dossier-absences/dossier-absences.component';
import { DossierAddressesComponent } from './dossier-addresses/dossier-addresses.component';
import { DossierOverviewComponent } from './dossier-overview/dossier-overview.component';
import { DossierGradesComponent } from './dossier-grades/dossier-grades.component';

export const dossierRoute: Route = {
Expand All @@ -13,7 +12,6 @@ export const dossierRoute: Route = {
path: '',
component: StudentDossierComponent,
children: [
{ path: '', component: DossierOverviewComponent },
{ path: 'addresses', component: DossierAddressesComponent },
{ path: 'absences', component: DossierAbsencesComponent },
{ path: 'grades', component: DossierGradesComponent },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div class="d-flex w-100 justify-content-between">
<erz-student-backlink
class="mb-2"
[link]="link$ | async"
[queryParams]="queryParams$ | async"
[link]="'../..'"
[queryParams]="state.backlinkQueryParams$ | async"
[studentId]="state.studentId$ | async"
[student]="data.profile && data.profile.student"
></erz-student-backlink>
Expand All @@ -28,6 +28,26 @@
</a>
</div>
</div>
<div class="py-3">
<!-- TODO: Use DossierPage -->
<a
[queryParams]="{ returnparams: state.returnParams$ | async }"
[routerLink]="[section]"
class="pl-3"
*ngFor="let section of ['addresses', 'absences', 'grades']"
>
<button
data-test-id="dossier-section-button"
type="button"
class="btn btn-outline-primary"
routerLinkActive="btn-primary"
#rla="routerLinkActive"
[class.btn-outline-primary]="!rla.isActive"
>
{{ 'dossier.' + section | translate }}
</button>
</a>
</div>
<div *ngIf="data.profile; else noProfile">
<router-outlet></router-outlet>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { map, switchMap } from 'rxjs';
import { DossierGradesService } from 'src/app/shared/services/dossier-grades.service';
import { DossierStateService } from '../../../services/dossier-state.service';

Expand All @@ -10,27 +9,11 @@ import { DossierStateService } from '../../../services/dossier-state.service';
providers: [DossierStateService, DossierGradesService],
changeDetection: ChangeDetectionStrategy.OnPush,
})

// TODO: on Destroy
export class StudentDossierComponent {
link$ = this.state.isOverview$.pipe(
map((isOverview) => (isOverview ? ['../..'] : ['.']))
);

queryParams$ = this.state.isOverview$.pipe(
switchMap((isOverview) =>
isOverview
? this.state.backlinkQueryParams$
: this.state.returnParams$.pipe(
map((returnparams) => {
return { returnparams };
})
)
)
);

constructor(
public state: DossierStateService,
public dossierGradesService: DossierGradesService
) {}
) {
this.state.currentDossier$.next('addresses');
}
}
5 changes: 2 additions & 3 deletions src/app/shared/services/dossier-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { BehaviorSubject, map, pluck, shareReplay, switchMap } from 'rxjs';
import { parseQueryString } from '../utils/url';
import { StudentProfileService } from './student-profile.service';

export type DossierPage = 'overview' | 'addresses' | 'absences' | 'grades';
export type DossierPage = 'addresses' | 'absences' | 'grades';
@Injectable()
export class DossierStateService {
isOverview$ = new BehaviorSubject<boolean>(true);
currentDossier$ = new BehaviorSubject<DossierPage>('overview');
currentDossier$ = new BehaviorSubject<DossierPage>('addresses');

studentId$ = this.route.paramMap.pipe(
map((params) => Number(params.get('id')))
Expand Down
2 changes: 0 additions & 2 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { TestsWeightPipe } from './pipes/test-weight.pipe';
import { TestPointsPipe } from './pipes/test-points.pipe';
import { PreserveLineHeightComponent } from './components/text/line/preserve-line-height.component';
import { DossierAbsencesComponent } from './components/student-dossier/dossier-absences/dossier-absences.component';
import { DossierOverviewComponent } from './components/student-dossier/dossier-overview/dossier-overview.component';
import { DossierAddressesComponent } from './components/student-dossier/dossier-addresses/dossier-addresses.component';
import { DossierGradesComponent } from './components/student-dossier/dossier-grades/dossier-grades.component';
import { DossierCourseTestsComponent } from './components/student-dossier/dossier-course-tests/dossier-course-tests.component';
Expand All @@ -53,7 +52,6 @@ const components = [
DateSelectComponent,
SelectComponent,
MultiselectComponent,
DossierOverviewComponent,
DossierAddressesComponent,
DossierAbsencesComponent,
StudentBacklinkComponent,
Expand Down