Skip to content

Commit

Permalink
Merge branch 'feat/CB2-14451' into feat/vs-edit-brandon-2
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonT95 committed Nov 29, 2024
2 parents ef93d48 + 11dcd2f commit 12f4288
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1>
</label>
<app-control-errors elementId="techRecord_manufactureMonth" [control]="$any(form.get('techRecord_manufactureMonth'))" />
<select govukSelect formControlName="techRecord_manufactureMonth">
<option [value]="option.value" *ngFor="let option of months">{{ option.label }}</option>
<option [value]="option.value" *ngFor="let option of MONTHS">{{ option.label }}</option>
</select>
</div>

Expand Down Expand Up @@ -122,7 +122,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_vehicleSubclass')"
label="Vehicle subclass"
formControlName="techRecord_vehicleSubclass"
[options]="subClassOptions"
[options]="VEHICLE_SUBCLASS_OPTIONS"
[tags]="[{ label: TagTypeLabels.REQUIRED, colour: TagType.RED }]"
></govuk-checkbox-group>
</ng-container>
Expand All @@ -133,7 +133,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_speedLimiterMrk')"
label="Speed limiter exempt"
formControlName="techRecord_speedLimiterMrk"
[options]="ExemptOrNotOptions"
[options]="EXEMPT_OR_NOT_OPTIONS"
[tags]="[{ colour: TagType.PURPLE, label: TagTypeLabels.PLATES }]"
></govuk-form-group-radio>

Expand All @@ -142,7 +142,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_tachoExemptMrk')"
label="Tacho exempt"
formControlName="techRecord_tachoExemptMrk"
[options]="ExemptOrNotOptions"
[options]="EXEMPT_OR_NOT_OPTIONS"
></govuk-form-group-radio>
</div>

Expand All @@ -151,15 +151,15 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_euroStandard')"
label="Euro standard"
formControlName="techRecord_euroStandard"
[options]="euroStandardOptions"
[options]="EMISSION_STANDARD_OPTIONS"
></govuk-form-group-radio>

<!-- Road friendly suspension -->
<govuk-form-group-radio
*ngIf="shouldDisplayFormControl('techRecord_roadFriendly')"
label="Road friendly suspension"
formControlName="techRecord_roadFriendly"
[options]="YesNoOptions"
[options]="YES_NO_OPTIONS"
[tags]="[{ colour: TagType.PURPLE, label: TagTypeLabels.PLATES }]"
></govuk-form-group-radio>

Expand All @@ -170,7 +170,7 @@ <h1>
</label>
<app-control-errors elementId="techRecord_suspensionType" [control]="$any(form.get('techRecord_suspensionType'))" />
<select govukSelect formControlName="techRecord_suspensionType">
<option [value]="option.value" *ngFor="let option of suspensionTypeOptions">{{ option.label }}</option>
<option [value]="option.value" *ngFor="let option of SUSPENSION_TYRE_OPTIONS">{{ option.label }}</option>
</select>
</div>

Expand All @@ -179,7 +179,7 @@ <h1>
<label> Fuel / propulsion system </label>
<app-control-errors elementId="techRecord_fuelPropulsionSystem" [control]="$any(form.get('techRecord_fuelPropulsionSystem'))" />
<select govukSelect formControlName="techRecord_fuelPropulsionSystem">
<option [value]="option.value" *ngFor="let option of fuelPropulsionSystemOptions">{{ option.label }}</option>
<option [value]="option.value" *ngFor="let option of FUEL_PROPULSION_SYSTEM_OPTIONS">{{ option.label }}</option>
</select>
</div>

Expand All @@ -188,7 +188,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_drawbarCouplingFitted')"
label="Drawbar coupling fitted"
formControlName="techRecord_drawbarCouplingFitted"
[options]="YesNoOptions"
[options]="YES_NO_OPTIONS"
></govuk-form-group-radio>

<!-- Vehicle class (HGV/Motorcycle/Small TRL/TRL Only) -->
Expand Down Expand Up @@ -249,7 +249,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_offRoad')"
label="Off road vehicle"
formControlName="techRecord_offRoad"
[options]="YesNoOptions"
[options]="YES_NO_OPTIONS"
></govuk-form-group-radio>

<!-- Frame description (TRL Only) -->
Expand All @@ -259,7 +259,7 @@ <h1>
</label>
<app-control-errors elementId="techRecord_frameDescription" [control]="$any(form.get('techRecord_frameDescription'))" />
<select govukSelect formControlName="techRecord_frameDescription">
<option [value]="option.value" *ngFor="let option of frameDescriptionOptions">{{ option.label }}</option>
<option [value]="option.value" *ngFor="let option of FRAME_DESCRIPTION_OPTIONS">{{ option.label }}</option>
</select>
</div>

Expand Down Expand Up @@ -345,7 +345,7 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_vehicleSize')"
label="Vehicle size"
formControlName="techRecord_vehicleSize"
[options]="vehicleSizeOptions"
[options]="VEHICLE_SIZE_OPTIONS"
[tags]="[{ colour: TagType.RED, label: TagTypeLabels.REQUIRED }]"
>
<div class="govuk-hint">
Expand Down Expand Up @@ -400,15 +400,15 @@ <h1>
*ngIf="shouldDisplayFormControl('techRecord_departmentalVehicleMarker')"
label="Departmental vehicle marker"
formControlName="techRecord_departmentalVehicleMarker"
[options]="YesNoOptions"
[options]="YES_NO_OPTIONS"
></govuk-form-group-radio>

<!-- Alteration marker -->
<govuk-form-group-radio
*ngIf="shouldDisplayFormControl('techRecord_alterationMarker')"
label="Alteration marker"
formControlName="techRecord_alterationMarker"
[options]="YesNoOptions"
[options]="YES_NO_OPTIONS"
></govuk-form-group-radio>

<ng-template #vehicleClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@ import {
ValidatorFn,
} from '@angular/forms';
import { TagType } from '@components/tag/tag.component';
import { EUVehicleCategory } from '@dvsa/cvs-type-definitions/types/v3/tech-record/enums/euVehicleCategory.enum.js';
import { EUVehicleCategory as HGVCategories } from '@dvsa/cvs-type-definitions/types/v3/tech-record/enums/euVehicleCategoryHgv.enum.js';
import { EUVehicleCategory as PSVCategories } from '@dvsa/cvs-type-definitions/types/v3/tech-record/enums/euVehicleCategoryPsv.enum.js';
import { VehicleClassDescription } from '@dvsa/cvs-type-definitions/types/v3/tech-record/enums/vehicleClassDescription.enum';
import { FuelPropulsionSystem } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete';
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 { CouplingTypeOptions } from '@models/coupling-type-enum';
import { MultiOption, MultiOptions } from '@models/options.model';
import { EmissionStandard } from '@models/test-types/emissions.enum';
import {
HgvPsvVehicleConfiguration,
TrlVehicleConfiguration,
VehicleConfiguration,
} from '@models/vehicle-configuration.enum';
import { VehicleSize } from '@models/vehicle-size.enum';
import {
FrameDescriptions,
FuelTypes,
V3TechRecordModel,
VehicleSizes,
VehicleSubclass,
VehicleTypes,
} from '@models/vehicle-tech-record.model';
ALL_EU_VEHICLE_CATEGORY_OPTIONS,
ALL_VEHICLE_CONFIGURATION_OPTIONS,
EMISSION_STANDARD_OPTIONS,
EXEMPT_OR_NOT_OPTIONS,
FRAME_DESCRIPTION_OPTIONS,
FUEL_PROPULSION_SYSTEM_OPTIONS,
HGV_EU_VEHICLE_CATEGORY_OPTIONS,
HGV_PSV_VEHICLE_CONFIGURATION_OPTIONS,
HGV_VEHICLE_CLASS_DESCRIPTION_OPTIONS,
MONTHS,
MOTORCYCLE_VEHICLE_CLASS_DESCRIPTION_OPTIONS,
PSV_EU_VEHICLE_CATEGORY_OPTIONS,
PSV_VEHICLE_CLASS_DESCRIPTION_OPTIONS,
SUSPENSION_TYRE_OPTIONS,
TRL_VEHICLE_CONFIGURATION_OPTIONS,
VEHICLE_SIZE_OPTIONS,
VEHICLE_SUBCLASS_OPTIONS,
YES_NO_OPTIONS,
} from '@models/options.model';
import { VehicleConfiguration } from '@models/vehicle-configuration.enum';
import { V3TechRecordModel, VehicleSizes, VehicleTypes } from '@models/vehicle-tech-record.model';
import { Store } from '@ngrx/store';
import { FormNodeWidth, TagTypeLabels } from '@services/dynamic-forms/dynamic-form.types';
import { TechnicalRecordService } from '@services/technical-record/technical-record.service';
Expand All @@ -47,11 +49,21 @@ type VehicleSectionForm = Partial<Record<keyof TechRecordType<'hgv' | 'car' | 'p
styleUrls: ['./vehicle-section-edit.component.scss'],
})
export class VehicleSectionEditComponent implements OnInit, OnDestroy {
protected readonly CouplingTypeOptions = CouplingTypeOptions;
protected readonly FormNodeWidth = FormNodeWidth;
protected readonly TagType = TagType;
protected readonly TagTypeLabels = TagTypeLabels;
protected readonly VehicleTypes = VehicleTypes;
readonly CouplingTypeOptions = CouplingTypeOptions;
readonly FormNodeWidth = FormNodeWidth;
readonly TagType = TagType;
readonly TagTypeLabels = TagTypeLabels;
readonly VehicleTypes = VehicleTypes;
readonly YES_NO_OPTIONS = YES_NO_OPTIONS;
readonly EXEMPT_OR_NOT_OPTIONS = EXEMPT_OR_NOT_OPTIONS;
readonly FUEL_PROPULSION_SYSTEM_OPTIONS = FUEL_PROPULSION_SYSTEM_OPTIONS;
readonly MONTHS = MONTHS;
readonly SUSPENSION_TYRE_OPTIONS = SUSPENSION_TYRE_OPTIONS;
readonly EMISSION_STANDARD_OPTIONS = EMISSION_STANDARD_OPTIONS;
readonly VEHICLE_SUBCLASS_OPTIONS = VEHICLE_SUBCLASS_OPTIONS;
readonly VEHICLE_SIZE_OPTIONS = VEHICLE_SIZE_OPTIONS;
readonly FRAME_DESCRIPTION_OPTIONS = FRAME_DESCRIPTION_OPTIONS;

fb = inject(FormBuilder);
store = inject(Store);
controlContainer = inject(ControlContainer);
Expand All @@ -76,23 +88,6 @@ export class VehicleSectionEditComponent implements OnInit, OnDestroy {
{ validators: [] }
);

ExemptOrNotOptions: MultiOption[] = [
{ value: true, label: 'Exempt' },
{ value: false, label: 'Not exempt' },
];

euroStandardOptions = [
{ label: '0.10 g/kWh Euro III PM', value: '0.10 g/kWh Euro 3 PM' },
...getOptionsFromEnum(EmissionStandard),
];

fuelPropulsionSystemOptions = [...getOptionsFromEnum(FuelTypes)];

YesNoOptions = [
{ value: true, label: 'Yes' },
{ value: false, label: 'No' },
];

ngOnInit(): void {
this.addControlsBasedOffVehicleType();

Expand Down Expand Up @@ -323,60 +318,27 @@ export class VehicleSectionEditComponent implements OnInit, OnDestroy {
get EUCategoryOptions() {
switch (this.techRecord()?.techRecord_vehicleType.toLowerCase()) {
case VehicleTypes.HGV:
return getOptionsFromEnum(HGVCategories);
return HGV_EU_VEHICLE_CATEGORY_OPTIONS;
case VehicleTypes.PSV:
return getOptionsFromEnum(PSVCategories);
case VehicleTypes.TRL:
case VehicleTypes.SMALL_TRL:
case VehicleTypes.LGV:
case VehicleTypes.CAR:
case VehicleTypes.MOTORCYCLE:
return getOptionsFromEnum(EUVehicleCategory);
return PSV_EU_VEHICLE_CATEGORY_OPTIONS;
default:
return getOptionsFromEnum(EUVehicleCategory);
return ALL_EU_VEHICLE_CATEGORY_OPTIONS;
}
}

get vehicleClassDescriptionOptions() {
switch (this.techRecord()?.techRecord_vehicleType.toLowerCase()) {
case VehicleTypes.HGV:
return [{ label: 'heavy goods vehicle', value: 'heavy goods vehicle' }];
return HGV_VEHICLE_CLASS_DESCRIPTION_OPTIONS;
case VehicleTypes.PSV:
return [
{
label: 'small psv (ie: less than or equal to 22 passengers)',
value: 'small psv (ie: less than or equal to 22 seats)',
},
{
label: 'large psv(ie: greater than or equal to 23 passengers)',
value: 'large psv(ie: greater than 23 seats)',
},
];
return PSV_VEHICLE_CLASS_DESCRIPTION_OPTIONS;
case VehicleTypes.TRL:
case VehicleTypes.SMALL_TRL:
case VehicleTypes.LGV:
case VehicleTypes.CAR:
return null;
case VehicleTypes.MOTORCYCLE:
return [
{ label: 'motorbikes over 200cc or with a sidecar', value: 'motorbikes over 200cc or with a sidecar' },
{ label: 'not applicable', value: 'not applicable' },
{
label: 'small psv (ie: less than or equal to 22 passengers)',
value: 'small psv (ie: less than or equal to 22 seats)',
},
{ label: 'motorbikes up to 200cc', value: 'motorbikes up to 200cc' },
{ label: 'trailer', value: 'trailer' },
{
label: 'large psv(ie: greater than or equal to 23 passengers)',
value: 'large psv(ie: greater than 23 seats)',
},
{ label: '3 wheelers', value: '3 wheelers' },
{ label: 'heavy goods vehicle', value: 'heavy goods vehicle' },
{ label: 'MOT class 4', value: 'MOT class 4' },
{ label: 'MOT class 7', value: 'MOT class 7' },
{ label: 'MOT class 5', value: 'MOT class 5' },
];
return MOTORCYCLE_VEHICLE_CLASS_DESCRIPTION_OPTIONS;
default:
return null;
}
Expand All @@ -386,54 +348,15 @@ export class VehicleSectionEditComponent implements OnInit, OnDestroy {
switch (this.techRecord()?.techRecord_vehicleType.toLowerCase()) {
case VehicleTypes.HGV:
case VehicleTypes.PSV:
return getOptionsFromEnum(HgvPsvVehicleConfiguration);
return HGV_PSV_VEHICLE_CONFIGURATION_OPTIONS;
case VehicleTypes.TRL:
case VehicleTypes.SMALL_TRL:
return getOptionsFromEnum(TrlVehicleConfiguration);
return TRL_VEHICLE_CONFIGURATION_OPTIONS;
default:
return getOptionsFromEnum(VehicleConfiguration);
return ALL_VEHICLE_CONFIGURATION_OPTIONS;
}
}

get months(): MultiOptions {
return [
{ value: 'January', label: 'January' },
{ value: 'February', label: 'Febraury' },
{ value: 'March', label: 'March' },
{ value: 'April', label: 'April' },
{ value: 'May', label: 'May' },
{ value: 'June', label: 'June' },
{ value: 'July', label: 'July' },
{ value: 'August', label: 'August' },
{ value: 'September', label: 'September' },
{ value: 'October', label: 'October' },
{ value: 'November', label: 'November' },
{ value: 'December', label: 'December' },
];
}

get suspensionTypeOptions(): MultiOptions {
return [
{ value: 'S', label: 'Steel' },
{ value: 'R', label: 'Rubber' },
{ value: 'A', label: 'Air' },
{ value: 'H', label: 'Hydraulic' },
{ value: 'O', label: 'Other' },
];
}

get subClassOptions(): MultiOptions {
return getOptionsFromEnum(VehicleSubclass);
}

get vehicleSizeOptions(): MultiOptions {
return getOptionsFromEnum(VehicleSize);
}

get frameDescriptionOptions(): MultiOptions {
return getOptionsFromEnum(FrameDescriptions);
}

get controlsBasedOffVehicleType() {
switch (this.technicalRecordService.getVehicleTypeWithSmallTrl(this.techRecord())) {
case VehicleTypes.HGV:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,21 @@
</dd>
</div>
</ng-container>
<ng-container *ngIf="
vm.techRecord_vehicleType === VehicleTypes.HGV ||
vm.techRecord_vehicleType === VehicleTypes.MOTORCYCLE ||
vm.techRecord_vehicleType === VehicleTypes.TRL">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Vehicle class</dt>
<dd class="govuk-summary-list__value" id="test-techRecord_vehicleClass">
{{ vm.techRecord_vehicleClass_description | defaultNullOrEmpty }}
</dd>
</div>
<ng-container *ngIf="vm.techRecord_vehicleType === VehicleTypes.HGV || vm.techRecord_vehicleType === VehicleTypes.TRL">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Vehicle class</dt>
<dd class="govuk-summary-list__value" id="test-techRecord_vehicleClass">
{{ vm.techRecord_vehicleClass_description | multiOption : HGV_VEHICLE_CLASS_DESCRIPTION_OPTIONS }}
</dd>
</div>
</ng-container>
<ng-container *ngIf="vm.techRecord_vehicleType === VehicleTypes.MOTORCYCLE">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Vehicle class</dt>
<dd class="govuk-summary-list__value" id="test-techRecord_vehicleClass_motorcycle">
{{ vm.techRecord_vehicleClass_description | multiOption : MOTORCYCLE_VEHICLE_CLASS_DESCRIPTION_OPTIONS }}
</dd>
</div>
</ng-container>
<ng-container
*ngIf="
Expand Down Expand Up @@ -246,7 +251,7 @@ <h3>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Vehicle class</dt>
<dd class="govuk-summary-list__value" id="test-techRecord_vehicleClass_psv">
{{ vm.techRecord_vehicleClass_description | defaultNullOrEmpty }}
{{ vm.techRecord_vehicleClass_description | multiOption : PSV_VEHICLE_CLASS_DESCRIPTION_OPTIONS }}
</dd>
</div>
<div class="govuk-summary-list__row">
Expand Down
Loading

0 comments on commit 12f4288

Please sign in to comment.