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 branch/qualification accordion #6409

Merged
merged 43 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6c0b50d
add a new component for select-qualification-type
kapppa-joe Oct 1, 2024
55e2f91
Update add-edit-qualification to have single form with year achieved …
duncanc19 Oct 1, 2024
5871c92
Delete qualification-form component and move content into add-edit-qu…
duncanc19 Oct 1, 2024
2e51a06
populate the content of qualification accordions
kapppa-joe Oct 1, 2024
80405d8
Add tests for prefilling inputs when existing qualification
duncanc19 Oct 2, 2024
473b1d1
Add displaying qualification name and group for existing qualifications
duncanc19 Oct 2, 2024
ada5982
Update existing qualifications with correct id and group
duncanc19 Oct 2, 2024
e859d37
store selected qualification to qualificationService on submit
kapppa-joe Oct 2, 2024
dabfe30
Fix bug where character count not updated when existing notes
duncanc19 Oct 2, 2024
8405e6c
add validation and prefill form
kapppa-joe Oct 2, 2024
0288329
Move notes box into reveal
duncanc19 Oct 2, 2024
6c02bc1
tidy up import, remove unused OnDestroy
kapppa-joe Oct 2, 2024
da3a222
remove commented out lines
kapppa-joe Oct 2, 2024
bd4f9f0
add one unit test, minor tidy ups
kapppa-joe Oct 2, 2024
9da51e8
amend setSelectedQualification to store the title as well
kapppa-joe Oct 3, 2024
03268e0
add a resolver for availableQualifications
kapppa-joe Oct 3, 2024
45ceaca
remove fdescribe, sort imports
kapppa-joe Oct 3, 2024
2334884
Update page to display and submit data from qualification service whe…
duncanc19 Oct 3, 2024
63013bb
patch a bug at GroupedRadioButtonAccordionComponent
kapppa-joe Oct 3, 2024
51772bc
remove unused imports
kapppa-joe Oct 3, 2024
25710e0
Add change link for new qualification records
duncanc19 Oct 3, 2024
00fe3f3
Navigate back to qualification selection page if no qualification fou…
duncanc19 Oct 3, 2024
c81b579
Increase gap between year achieved and notes inputs
duncanc19 Oct 3, 2024
df4a5f9
Clear selectedQualification in service on valid submission
duncanc19 Oct 3, 2024
d5e9984
Clear data in qualification service on click of cancel
duncanc19 Oct 3, 2024
8ad8c2f
address PR comments
kapppa-joe Oct 3, 2024
8a8e504
Merge pull request #6376 from NMDSdevopsServiceAdm/feat/1520-qualific…
kapppa-joe Oct 3, 2024
500c543
Merge qualification accordion feature branch in
duncanc19 Oct 3, 2024
a2cabc3
Convert qualification type to lower case unless NVQ
duncanc19 Oct 4, 2024
f8c3783
Fix back navigation on page refresh to go to previous accordion page
duncanc19 Oct 4, 2024
93520e9
Set width of column for qualification title dynamically to have Chang…
duncanc19 Oct 4, 2024
ce8bab7
Use custom styling to display Change link to have fixed gap between t…
duncanc19 Oct 4, 2024
89a457a
Reduce spacing on submit buttons
duncanc19 Oct 4, 2024
a14e85e
Fix cancel link on accordion page to go back to worker training record
duncanc19 Oct 4, 2024
13c0b14
Merge remote-tracking branch 'origin' into featureBranch/qualificatio…
duncanc19 Oct 4, 2024
8a4ce67
Merge branch 'featureBranch/qualification-accordion' into feat/1521-q…
duncanc19 Oct 4, 2024
edd1958
Merge pull request #6378 from NMDSdevopsServiceAdm/feat/1521-qualific…
duncanc19 Oct 8, 2024
157002a
Merge main into branch
duncanc19 Nov 5, 2024
f6e1e16
Use training and quals summary url to ensure navigation always succes…
duncanc19 Nov 5, 2024
1743d39
Remove unneeded previousUrl
duncanc19 Nov 5, 2024
1d1fd1b
Rename training and quals summary url variable for clarity
duncanc19 Nov 5, 2024
8f2ee0a
Reintroduce previousUrl to handle cases when navigated to training fr…
duncanc19 Nov 6, 2024
da25d6f
Merge pull request #6408 from NMDSdevopsServiceAdm/fix/navigation-aft…
duncanc19 Nov 6, 2024
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
2 changes: 1 addition & 1 deletion frontend/src/app/core/model/qualification.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface AvailableQualificationsResponse {
export interface QualificationRequest {
type: QualificationType;
qualification: Qualification;
year?: 2014;
year?: number;
notes?: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { of, Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';

import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router';
import { AvailableQualificationsResponse } from '@core/model/qualification.model';
import { EstablishmentService } from '@core/services/establishment.service';
import { WorkerService } from '@core/services/worker.service';

@Injectable()
export class AvailableQualificationsResolver implements Resolve<AvailableQualificationsResponse[]> {
constructor(
private router: Router,
private workerService: WorkerService,
private establishmentService: EstablishmentService,
) {}

resolve(route: ActivatedRouteSnapshot): Observable<AvailableQualificationsResponse[]> {
const workplaceUid = route.paramMap.get('establishmentuid') || this.establishmentService.establishmentId;
const workerUid = route.paramMap.get('id') || this.workerService.worker.uid;

return this.workerService.getAllAvailableQualifications(workplaceUid, workerUid).pipe(
catchError(() => {
this.router.navigate(['/problem-with-the-service']);
return of(null);
}),
);
}
}
22 changes: 20 additions & 2 deletions frontend/src/app/core/services/qualification.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { QualificationLevel } from '@core/model/qualification.model';
import { Qualification, QualificationLevel, QualificationType } from '@core/model/qualification.model';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from 'src/environments/environment';
Expand All @@ -9,9 +9,27 @@ import { environment } from 'src/environments/environment';
providedIn: 'root',
})
export class QualificationService {
protected _selectedQualification: Qualification = null;

constructor(private http: HttpClient) {}

getQualifications(): Observable<QualificationLevel[]> {
return this.http.get<any>(`${environment.appRunnerEndpoint}/api/qualification`).pipe(map((res) => res.qualifications));
return this.http
.get<any>(`${environment.appRunnerEndpoint}/api/qualification`)
.pipe(map((res) => res.qualifications));
}

public get selectedQualification() {
return this._selectedQualification;
}

public setSelectedQualification(id: number, title: string, group: QualificationType) {
if (id && title && group) {
this._selectedQualification = { id, title, group };
}
}

public clearSelectedQualification() {
this._selectedQualification = null;
}
}
20 changes: 19 additions & 1 deletion frontend/src/app/core/services/worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { TrainingAndQualificationRecords } from '@core/model/trainingAndQualifications.model';
import { URLStructure } from '@core/model/url.model';
import { Worker, WorkerEditResponse, WorkersResponse } from '@core/model/worker.model';
import { BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, forkJoin, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from 'src/environments/environment';
import { Contracts } from '@core/model/contracts.enum';
Expand Down Expand Up @@ -191,6 +191,24 @@ export class WorkerService {
.pipe(map((res) => res.qualifications));
}

getAllAvailableQualifications(
workplaceUid: string,
workerUid: string,
): Observable<AvailableQualificationsResponse[]> {
const allQualificationTypes: QualificationType[] = Object.values(QualificationType);
const allResponses$ = allQualificationTypes.map((type) => {
const params = new HttpParams().append('type', type);
return this.http.get<AvailableQualificationsResponse>(
`${environment.appRunnerEndpoint}/api/establishment/${workplaceUid}/worker/${workerUid}/qualification/available`,
{
params,
},
);
});

return forkJoin(allResponses$);
}

createQualification(workplaceUid: string, workerId: string, record: QualificationRequest) {
return this.http.post<QualificationRequest>(
`${environment.appRunnerEndpoint}/api/establishment/${workplaceUid}/worker/${workerId}/qualification`,
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/app/core/test-utils/MockQualificationsService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { QualificationLevel } from '@core/model/qualification.model';
import { Qualification, QualificationLevel, QualificationType } from '@core/model/qualification.model';
import { QualificationService } from '@core/services/qualification.service';
import { Observable, of } from 'rxjs';

Expand All @@ -19,4 +20,14 @@ export class MockQualificationService extends QualificationService {
{ id: 10, level: `Don't know` },
]);
}

public static factory(selectedQualification: Qualification) {
return (httpClient: HttpClient) => {
const service = new QualificationService(httpClient);
const { id, title, group } = selectedQualification;
service.setSelectedQualification(id, title, group as QualificationType);

return service;
};
}
}
135 changes: 134 additions & 1 deletion frontend/src/app/core/test-utils/MockWorkerService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Params } from '@angular/router';
import { QualificationsByGroup } from '@core/model/qualification.model';
import { QualificationsByGroup, QualificationType } from '@core/model/qualification.model';
import {
CreateTrainingRecordResponse,
MultipleTrainingResponse,
Expand All @@ -13,6 +13,8 @@ import { NewWorkerMandatoryInfo, WorkerService } from '@core/services/worker.ser
import { build, fake, oneOf, perBuild, sequence } from '@jackfranklin/test-data-bot';
import { Observable, of } from 'rxjs';

import { AvailableQualificationsResponse } from '../model/qualification.model';

export const workerBuilder = build('Worker', {
fields: {
id: sequence(),
Expand Down Expand Up @@ -238,6 +240,130 @@ export const qualificationsByGroup = {
],
} as QualificationsByGroup;

export const mockAvailableQualifications: AvailableQualificationsResponse[] = [
{
type: QualificationType.NVQ,
count: 2,
qualifications: [
{
id: 93,
title: 'Care NVQ (level 2)',
level: '2',
code: 4,
},
{
id: 94,
title: 'Care NVQ (level 3)',
level: '3',
code: 5,
},
],
},
{
type: QualificationType.Certificate,
count: 2,
qualifications: [
{
id: 30,
title: 'Activity provision in social care (level 3)',
level: '3',
code: 42,
},
{
id: 31,
title: 'Adult care (level 4)',
level: '4',
code: 110,
},
],
},
{
type: QualificationType.Degree,
count: 2,
qualifications: [
{
id: 71,
title: 'Combined nursing and social work degree (level 6)',
level: '6',
code: 18,
},
{
id: 136,
title: 'Health and social care degree (level 6)',
level: '6',
code: 144,
},
],
},
{
type: QualificationType.Award,
count: 2,
qualifications: [
{
id: 1,
title: 'Advanced Award in Social Work (AASW, level 7)',
level: '7',
code: 20,
},
{
id: 5,
title: 'Awareness of dementia (level 3)',
level: '3',
code: 49,
from: '2010-09-01',
},
],
},
{
type: QualificationType.Diploma,
count: 1,
qualifications: [
{
id: 74,
title: 'Adult care (level 4)',
level: '4',
code: 109,
},
],
},
{
type: QualificationType.Apprenticeship,
count: 3,
qualifications: [
{
id: 121,
title: 'Adult care worker (standard, level 2)',
level: '2',
code: 302,
},
{
id: 124,
title: 'Degree registered nurse (standard, level 6)',
level: '6',
code: 310,
},
],
},
{
type: QualificationType.Other,
count: 2,
qualifications: [
{
id: 113,
title: 'Other relevant professional qualification',
level: null,
code: 33,
},
{
id: 119,
title: 'Other qualification',
level: null,
code: 39,
},
],
},
];

export const trainingRecord = {
id: 10,
uid: 'someTrainingUid',
Expand Down Expand Up @@ -343,6 +469,13 @@ export class MockWorkerService extends WorkerService {
): Observable<CreateTrainingRecordResponse> {
return of(trainingRecord);
}

getAllAvailableQualifications(
workplaceUid: string,
workerUid: string,
): Observable<AvailableQualificationsResponse[]> {
return of(mockAvailableQualifications);
}
}

@Injectable()
Expand Down
Loading
Loading