-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/CB2-10033 - Additional Examiner Note (#1448)
* feat(cb2-10241): update adr notes to use custom component * feat(cb2-11250): format table * feat(cb2-11250): set up router link * feat(cb2-11250): blank page link working * feat(cb2-11250): revert unnecessary changes * feat(cb2-11250): amend routing function * feat(cb2-11250): fix linting and add unit test * feat(cb2-11250): fix linting and add unit test * feat(cb2-11250): update link design * feat(cb2-11250): fix button link styling * feat(cb2-10033): basic setup and grabbed selected note from record * feat(cb2-10033): stash for mobbing * feat(cb2-10033): hook form up to display note which is to be edited * feat(cb2-10033): set up model binding to component * feat(cb2-10033): use correct directive and basic form validation * feat(cb2-10033): amend routing title for notifiable alteration * feat(cb2-10033): remove validation as requirements confirmed not needed * feat(cb2-10033): implement state management solution * feat(cb2-10033): fix display for summary screen * feat(cb2-10033): refactor state and data handling approach * feat(cb2-10033): reducer tests * feat(cb2-10033): basic unit testing draft * feat(cb2-10033): unit testing * feat(cb2-10033): linting fix * feat(cb2-10033): fix review screen * feat(cb2-10033): git stash for mobbing * feat(cb2-10033): add logic to hide collapse function and fix missing acs * feat(cb2-10033): move title from component to templates * feat(cb2-10033): acordion issues solved --------- Co-authored-by: Brandon Thomas-Davies <87308252+BrandonT95@users.noreply.github.com> Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk> Co-authored-by: Thomas Evans <36958694+tomevs88@users.noreply.github.com>
- Loading branch information
1 parent
5b4e5c1
commit 3269b25
Showing
19 changed files
with
410 additions
and
22 deletions.
There are no files selected for viewing
32 changes: 31 additions & 1 deletion
32
...rd-edit-additional-examiner-note/tech-record-edit-additional-examiner-note.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
<div>This is a blank page right now.</div> | ||
<div *ngIf="currentTechRecord"> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<dl class="govuk-summary-list"> | ||
<h1 class="govuk-heading-l">Edit Additional Examiner Note</h1> | ||
<div class="parent-div"> | ||
<td class="govuk-heading-s">Date</td> | ||
<td class="table-value">{{ examinerNoteObj.createdAtDate | date: 'dd/MM/yyyy' | defaultNullOrEmpty }}</td> | ||
<td class="govuk-heading-s">Created by</td> | ||
<td class="table-value">{{ examinerNoteObj.lastUpdatedBy }}</td> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<form [formGroup]="form"> | ||
<app-text-area | ||
#examinerNote | ||
formControlName="additionalExaminerNote" | ||
name="AdditionalExaminerNote" | ||
[width]="width.L" | ||
(ngModelChange)="ngOnChanges(examinerNote.value)" | ||
> | ||
</app-text-area> | ||
</form> | ||
</div> | ||
</dl> | ||
</div> | ||
</div> | ||
<app-button-group> | ||
<app-button id="submit-examiner-note" (clicked)="handleSubmit()">Save</app-button> | ||
<app-button id="cancel-amend-examiner-note" design="link" data-module="govuk-button" (clicked)="navigateBack()">Cancel</app-button> | ||
</app-button-group> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.parent-div { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
.table-value { | ||
margin-left: 1%; | ||
margin-right: 1%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 100 additions & 2 deletions
102
...cord-edit-additional-examiner-note/tech-record-edit-additional-examiner-note.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,108 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { TechnicalRecordService } from '@services/technical-record/technical-record.service'; | ||
import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type'; | ||
import { ReplaySubject, take, takeUntil } from 'rxjs'; | ||
import { GlobalErrorService } from '@core/components/global-error/global-error.service'; | ||
import { | ||
CustomFormControl, | ||
FormNodeEditTypes, | ||
FormNodeTypes, | ||
FormNodeWidth, | ||
} from '@forms/services/dynamic-form.types'; | ||
import { FormGroup, Validators } from '@angular/forms'; | ||
import { Store } from '@ngrx/store'; | ||
import { State } from '@store/index'; | ||
import { updateExistingADRAdditionalExaminerNote } from '@store/technical-records'; | ||
import { AdditionalExaminerNotes } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete'; | ||
|
||
@Component({ | ||
selector: 'tech-record-edit-additional-examiner-note', | ||
templateUrl: './tech-record-edit-additional-examiner-note.component.html', | ||
styleUrls: ['./tech-record-edit-additional-examiner-note.component.scss'], | ||
}) | ||
export class TechRecordEditAdditionalExaminerNoteComponent { | ||
export class TechRecordEditAdditionalExaminerNoteComponent implements OnInit { | ||
currentTechRecord!: TechRecordType<'hgv' | 'trl' | 'lgv'>; | ||
examinerNoteIndex!: number; | ||
editedExaminerNote: string = ''; | ||
originalExaminerNote: string = ''; | ||
examinerNoteObj!: AdditionalExaminerNotes; | ||
destroy$ = new ReplaySubject<boolean>(1); | ||
form!: FormGroup; | ||
formControl!: CustomFormControl; | ||
|
||
constructor( | ||
private router: Router, | ||
private route: ActivatedRoute, | ||
private technicalRecordService: TechnicalRecordService, | ||
private globalErrorService: GlobalErrorService, | ||
private store: Store<State>, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.getTechRecord(); | ||
this.getExaminerNote(); | ||
this.setupForm(); | ||
} | ||
|
||
getTechRecord() { | ||
this.technicalRecordService.techRecord$.pipe(takeUntil(this.destroy$)).subscribe((currentTechRecord) => { | ||
this.currentTechRecord = currentTechRecord as TechRecordType<'hgv' | 'lgv' | 'trl'>; | ||
}); | ||
} | ||
|
||
getExaminerNote() { | ||
this.route.params.pipe(take(1)).subscribe((params) => { | ||
this.examinerNoteIndex = params['examinerNoteIndex']; | ||
}); | ||
const additionalExaminerNotes = this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes; | ||
if (additionalExaminerNotes) { | ||
const examinerNote = additionalExaminerNotes[this.examinerNoteIndex].note; | ||
if (examinerNote) { | ||
this.examinerNoteObj = additionalExaminerNotes[this.examinerNoteIndex]; | ||
this.originalExaminerNote = examinerNote; | ||
this.editedExaminerNote = examinerNote; | ||
} | ||
} | ||
} | ||
|
||
setupForm() { | ||
this.formControl = new CustomFormControl({ | ||
name: 'additionalExaminerNote', type: FormNodeTypes.CONTROL, | ||
}, '', [Validators.required]); | ||
this.form = new FormGroup({ | ||
additionalExaminerNote: this.formControl, | ||
}); | ||
this.formControl.patchValue(this.editedExaminerNote); | ||
} | ||
|
||
navigateBack() { | ||
this.globalErrorService.clearErrors(); | ||
void this.router.navigate(['../../'], { relativeTo: this.route }); | ||
} | ||
|
||
handleSubmit(): void { | ||
if (this.originalExaminerNote !== this.editedExaminerNote) { | ||
this.store.dispatch( | ||
updateExistingADRAdditionalExaminerNote({ | ||
examinerNoteIndex: this.examinerNoteIndex, | ||
additionalExaminerNote: this.editedExaminerNote, | ||
}), | ||
); | ||
} | ||
this.navigateBack(); | ||
} | ||
|
||
ngOnChanges(examinerNote: string) { | ||
this.editedExaminerNote = examinerNote; | ||
} | ||
|
||
get editTypes(): typeof FormNodeEditTypes { | ||
return FormNodeEditTypes; | ||
} | ||
|
||
get width(): typeof FormNodeWidth { | ||
return FormNodeWidth; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.