From 250cd9f3654142e05039b6426b267cf7b68f1a14 Mon Sep 17 00:00:00 2001 From: Thomas Crawley Date: Thu, 12 Dec 2024 10:12:11 +0000 Subject: [PATCH 1/6] fix(CB2-14459): fix additional disabled properties added by mistake (#1670) * fix(CB2-14449): fix additional disabled properties added by mistake * feat(CB2-14451): fix number of seats on psv * feat(CB2-14459): fix body description code --- .../govuk-form-group-input.component.html | 17 ++++++++++++++++- .../body-section-edit.component.ts | 10 +++++----- .../vehicle-section-edit.component.html | 2 +- .../vehicle-section-edit.component.ts | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/app/forms/components/govuk-form-group-input/govuk-form-group-input.component.html b/src/app/forms/components/govuk-form-group-input/govuk-form-group-input.component.html index db3ea46cba..903a203d56 100644 --- a/src/app/forms/components/govuk-form-group-input/govuk-form-group-input.component.html +++ b/src/app/forms/components/govuk-form-group-input/govuk-form-group-input.component.html @@ -31,7 +31,6 @@

[class.govuk-radios__input--error]="hasError" [(ngModel)]="value" (ngModelChange)="onChange($event)" - type="text" (blur)="onTouched()" [class]="style" [disabled]="control?.disabled || false" @@ -59,4 +58,20 @@

+ + + diff --git a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts index db78fba07e..40b9bb1cc4 100644 --- a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts +++ b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts @@ -136,16 +136,16 @@ export class BodySectionEditComponent implements OnInit, OnDestroy { get hgvAndTrailerFields(): Partial, FormControl>> { return { - techRecord_make: this.fb.control({ value: null, disabled: true }, [ + techRecord_make: this.fb.control(null, [ this.commonValidators.maxLength(20, 'Body make must be less than or equal to 20'), ]), techRecord_model: this.fb.control(null, [ this.commonValidators.maxLength(20, 'Body model must be less than or equal to 20'), ]), - techRecord_bodyType_description: this.fb.control({ value: null, disabled: true }, [ + techRecord_bodyType_description: this.fb.control(null, [ this.commonValidators.required('Body type is required'), ]), - techRecord_bodyType_code: this.fb.control({ value: null, disabled: true }, []), + techRecord_bodyType_code: this.fb.control(null, []), techRecord_brakes_dtpNumber: this.fb.control(null), techRecord_functionCode: this.fb.control(null, [ this.commonValidators.maxLength(1, 'Function code must be less than or equal to 1'), @@ -189,8 +189,8 @@ export class BodySectionEditComponent implements OnInit, OnDestroy { techRecord_bodyModel: this.fb.control(null, [ this.commonValidators.maxLength(20, 'Body model must be less than or equal to 20'), ]), - techRecord_bodyType_code: this.fb.control({ value: null, disabled: true }, []), - techRecord_bodyType_description: this.fb.control({ value: null, disabled: true }, [ + techRecord_bodyType_code: this.fb.control(null, []), + techRecord_bodyType_description: this.fb.control(null, [ this.commonValidators.required('Body type is required'), ]), techRecord_modelLiteral: this.fb.control(null, [ diff --git a/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.html b/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.html index 78c3bfc8b6..2f0e1d34f6 100644 --- a/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.html +++ b/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.html @@ -264,7 +264,7 @@

label="Number of seat belts" [tags]="[{ label: TagTypeLabels.REQUIRED, colour: TagType.RED }]" formControlName="techRecord_numberOfSeatbelts" - type="number" + type="numericString" > diff --git a/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.ts b/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.ts index 7068a2a47e..b1c5237a16 100644 --- a/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.ts +++ b/src/app/forms/custom-sections/vehicle-section/vehicle-section-edit/vehicle-section-edit.component.ts @@ -170,7 +170,7 @@ export class VehicleSectionEditComponent implements OnInit, OnDestroy { this.handlePsvPassengersChange(), ]), techRecord_vehicleSize: this.fb.control(null), - techRecord_numberOfSeatbelts: this.fb.control(null, [ + techRecord_numberOfSeatbelts: this.fb.control(null, [ this.commonValidators.max(99, 'Number of seat belts must be less than or equal to 99'), ]), techRecord_seatbeltInstallationApprovalDate: this.fb.control(null, [ From 84cb3c5573c9813c195e9b3d92fb63d1eb25f0a3 Mon Sep 17 00:00:00 2001 From: pbardy2000 <146740183+pbardy2000@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:31:22 +0000 Subject: [PATCH 2/6] feat(CB2-14459): update editing tech record --- .../body-section-edit/body-section-edit.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts index 40b9bb1cc4..e26741f492 100644 --- a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts +++ b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts @@ -76,6 +76,7 @@ export class BodySectionEditComponent implements OnInit, OnDestroy { techRecord_chassisMake: modelBase.psvChassisMake, techRecord_chassisModel: modelBase.psvChassisModel, }); + this.technicalRecordService.updateEditingTechRecord({ ...this.techRecord(), ...this.form.getRawValue() }); this.cdr.detectChanges(); } } From d43cd1cee24492d5b3ab20841fb418372d01a1ec Mon Sep 17 00:00:00 2001 From: Thomas Crawley Date: Thu, 12 Dec 2024 10:55:32 +0000 Subject: [PATCH 3/6] feat(CB2-14459): add missing vehicle type check --- .../tech-record-summary/tech-record-summary.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts index 2d8401b372..585393c15a 100644 --- a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts +++ b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts @@ -186,7 +186,7 @@ export class TechRecordSummaryComponent implements OnInit, OnDestroy, AfterViewI if (!value) { return; } - if (value === 'articulated') { + if (this.techRecordCalculated?.techRecord_vehicleType === VehicleTypes.HGV && value === 'articulated') { this.form.patchValue({ techRecord_bodyType_description: 'articulated', techRecord_bodyType_code: 'a', From 4969fc92f8ea30a7989beb067c4d50350e4718e0 Mon Sep 17 00:00:00 2001 From: Thomas Crawley Date: Thu, 12 Dec 2024 11:19:51 +0000 Subject: [PATCH 4/6] feat(CB2-14459): handle body type description change --- .../body-section-edit.component.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts index e26741f492..3e72e5bcaa 100644 --- a/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts +++ b/src/app/forms/custom-sections/body-section/body-section-edit/body-section-edit.component.ts @@ -4,7 +4,12 @@ import { TagType } from '@components/tag/tag.component'; import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type'; import { getOptionsFromEnum } from '@forms/utils/enum-map'; import { CommonValidatorsService } from '@forms/validators/common-validators.service'; -import { BodyTypeCode, vehicleBodyTypeCodeMap } from '@models/body-type-enum'; +import { + BodyTypeCode, + BodyTypeDescription, + vehicleBodyTypeCodeMap, + vehicleBodyTypeDescriptionMap, +} from '@models/body-type-enum'; import { FUNCTION_CODE_OPTIONS, MultiOptions } from '@models/options.model'; import { PsvMake, ReferenceDataModelBase, ReferenceDataResourceType } from '@models/reference-data.model'; import { V3TechRecordModel, VehicleTypes } from '@models/vehicle-tech-record.model'; @@ -63,6 +68,28 @@ export class BodySectionEditComponent implements OnInit, OnDestroy { } }); } + this.form + .get('techRecord_bodyType_description') + ?.valueChanges.pipe(takeUntil(this.destroy$)) + .subscribe((value) => { + if (value) { + this.handleBodyTypeDescriptionChange(value); + } + }); + } + + handleBodyTypeDescriptionChange(value: string) { + const vehicleType = this.techRecord().techRecord_vehicleType; + const bodyConfig = vehicleType === 'hgv' ? `${this.techRecord().techRecord_vehicleConfiguration}Hgv` : vehicleType; + const bodyTypes = vehicleBodyTypeDescriptionMap.get(bodyConfig as VehicleTypes) as Map< + BodyTypeDescription, + BodyTypeCode + >; + this.form.patchValue({ + techRecord_bodyType_code: bodyTypes.get(value as BodyTypeDescription), + }); + this.technicalRecordService.updateEditingTechRecord({ ...this.techRecord(), ...this.form.getRawValue() }); + this.cdr.detectChanges(); } handleDTpNumberChange(refData: ReferenceDataModelBase) { From 7859061933ea9895a21e26ddcb76d6a727e8d395 Mon Sep 17 00:00:00 2001 From: Thomas Crawley Date: Thu, 12 Dec 2024 13:16:50 +0000 Subject: [PATCH 5/6] feat(CB2-14459): add changes to feature flag logic --- .../tech-record-summary.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts index 585393c15a..f1f64dbd4f 100644 --- a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts +++ b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts @@ -259,20 +259,20 @@ export class TechRecordSummaryComponent implements OnInit, OnDestroy, AfterViewI addCustomSectionsBasedOffFlag(): CustomFormGroup[] { const sections = []; - if (!this.featureToggleService.isFeatureEnabled('FsBody')) { - sections.push(this.body.form); + if (!this.featureToggleService.isFeatureEnabled('FsBody') && this.body) { + sections.push(this.body?.form); } - if (!this.featureToggleService.isFeatureEnabled('FsDimensions')) { - sections.push(this.dimensions.form); + if (!this.featureToggleService.isFeatureEnabled('FsDimensions') && this.dimensions) { + sections.push(this.dimensions?.form); } - if (!this.featureToggleService.isFeatureEnabled('FsTyres')) { - sections.push(this.tyres.form); + if (!this.featureToggleService.isFeatureEnabled('FsTyres') && this.tyres) { + sections.push(this.tyres?.form); } - if (!this.featureToggleService.isFeatureEnabled('FsWeights')) { - sections.push(this.weights.form); + if (!this.featureToggleService.isFeatureEnabled('FsWeights') && this.weights) { + sections.push(this.weights?.form); } - if (!this.featureToggleService.isFeatureEnabled('FsApprovalType')) { - sections.push(this.approvalType.form); + if (!this.featureToggleService.isFeatureEnabled('FsApprovalType') && this.approvalType) { + sections.push(this.approvalType?.form); } return sections; } From f0631cd3024a18d26edf69a24891291ed0f80424 Mon Sep 17 00:00:00 2001 From: Thomas Crawley Date: Thu, 12 Dec 2024 13:39:27 +0000 Subject: [PATCH 6/6] feat(CB2-14459): add changes to feature flag logic --- .../tech-record-summary.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts index f1f64dbd4f..4e1c4d815a 100644 --- a/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts +++ b/src/app/features/tech-record/components/tech-record-summary/tech-record-summary.component.ts @@ -259,20 +259,20 @@ export class TechRecordSummaryComponent implements OnInit, OnDestroy, AfterViewI addCustomSectionsBasedOffFlag(): CustomFormGroup[] { const sections = []; - if (!this.featureToggleService.isFeatureEnabled('FsBody') && this.body) { - sections.push(this.body?.form); + if (!this.featureToggleService.isFeatureEnabled('FsBody') && this.body?.form) { + sections.push(this.body.form); } - if (!this.featureToggleService.isFeatureEnabled('FsDimensions') && this.dimensions) { - sections.push(this.dimensions?.form); + if (!this.featureToggleService.isFeatureEnabled('FsDimensions') && this.dimensions?.form) { + sections.push(this.dimensions.form); } - if (!this.featureToggleService.isFeatureEnabled('FsTyres') && this.tyres) { - sections.push(this.tyres?.form); + if (!this.featureToggleService.isFeatureEnabled('FsTyres') && this.tyres?.form) { + sections.push(this.tyres.form); } - if (!this.featureToggleService.isFeatureEnabled('FsWeights') && this.weights) { - sections.push(this.weights?.form); + if (!this.featureToggleService.isFeatureEnabled('FsWeights') && this.weights?.form) { + sections.push(this.weights.form); } - if (!this.featureToggleService.isFeatureEnabled('FsApprovalType') && this.approvalType) { - sections.push(this.approvalType?.form); + if (!this.featureToggleService.isFeatureEnabled('FsApprovalType') && this.approvalType?.form) { + sections.push(this.approvalType.form); } return sections; }