Skip to content

Commit

Permalink
feat(cb2-10210): add M145 statement (#1374)
Browse files Browse the repository at this point in the history
* feat(cb2-10210): add M145 statement

* feat(cb2-10210): use custom view component for styling + labelling
  • Loading branch information
pbardy2000 committed Feb 5, 2024
1 parent 63e4835 commit 2f3b427
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@angular/router": "^15.2.8",
"@azure/msal-angular": "^2.5.12",
"@azure/msal-browser": "^2.38.3",
"@dvsa/cvs-type-definitions": "^5.1.0",
"@dvsa/cvs-type-definitions": "^5.1.2",
"@ngrx/effects": "^15.4.0",
"@ngrx/entity": "^15.4.0",
"@ngrx/router-store": "^15.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h4 class="govuk-heading-m mb-0">{{ control.value.meta.label }}</h4>

<ng-template #subtitleTemplate let-control="control">
<ng-container *ngIf="!(control.value.meta && control.value.meta.hide)">
<ng-container *ngIf="!edit">
<ng-container *ngIf="!edit && control.value.meta.viewType !== formNodeViewTypes.HIDDEN">
<tr class="govuk-table__row">
<td colspan="2" class="govuk-table__cell">
<h4 class="govuk-heading-s mb-0">{{ control.value.meta.label }}</h4>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ng-container *ngIf="control">
<table class="govuk-table m-0">
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<td class="govuk-table__cell border-b-0" [style.width.%]="30">
<b>M145:</b>
</td>
<td class="govuk-table__cell border-b-0 break-words">{{ control.value | defaultNullOrEmpty }}</td>
</tr>
</tbody>
</table>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.m-0 {
margin: 0;
}

.break-words {
word-break: break-word;
}

.border-b-0 {
border-bottom-width: 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import {
FormsModule, NG_VALUE_ACCESSOR, NgControl, ReactiveFormsModule,
} from '@angular/forms';
import { DynamicFormsModule } from '@forms/dynamic-forms.module';
import { CustomFormControl, FormNodeTypes } from '@forms/services/dynamic-form.types';
import { provideMockStore } from '@ngrx/store/testing';
import { State, initialAppState } from '@store/index';
import { AdrTankDetailsM145ViewComponent } from './adr-tank-details-m145-view.component';

describe('AdrTankDetailsM145ViewComponent', () => {
let component: AdrTankDetailsM145ViewComponent;
let fixture: ComponentFixture<AdrTankDetailsM145ViewComponent>;

const control = new CustomFormControl({
name: 'techRecord_adrDetails_m145Statement',
type: FormNodeTypes.CONTROL,
value: [],
});

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AdrTankDetailsM145ViewComponent],
imports: [DynamicFormsModule, FormsModule, ReactiveFormsModule],
providers: [
provideMockStore<State>({ initialState: initialAppState }),
{ provide: NG_VALUE_ACCESSOR, useExisting: AdrTankDetailsM145ViewComponent, multi: true },
{ provide: NgControl, useValue: { control } },
],
})
.compileComponents();

fixture = TestBed.createComponent(AdrTankDetailsM145ViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { BaseControlComponent } from '@forms/components/base-control/base-control.component';

@Component({
selector: 'app-adr-tank-details-m145-view',
templateUrl: './adr-tank-details-m145-view.component.html',
styleUrls: ['./adr-tank-details-m145-view.component.scss'],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: AdrTankDetailsM145ViewComponent,
multi: true,
},
],
})
export class AdrTankDetailsM145ViewComponent extends BaseControlComponent {

}
2 changes: 2 additions & 0 deletions src/app/forms/dynamic-forms.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { ToUppercaseDirective } from './directives/app-to-uppercase.directive';
import { TrimWhitespaceDirective } from './directives/app-trim-whitespace.directive';
import { PrefixDirective } from './directives/prefix.directive';
import { SuffixDirective } from './directives/suffix.directive';
import { AdrTankDetailsM145ViewComponent } from './custom-sections/adr-tank-details-m145-view/adr-tank-details-m145-view.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -133,6 +134,7 @@ import { SuffixDirective } from './directives/suffix.directive';
AdrTankDetailsInitialInspectionViewComponent,
AdrTankStatementUnNumberViewComponent,
AdrCertificateHistoryComponent,
AdrTankDetailsM145ViewComponent,
],
imports: [CommonModule, FormsModule, ReactiveFormsModule, SharedModule, RouterModule],
exports: [
Expand Down
11 changes: 11 additions & 0 deletions src/app/forms/templates/general/adr-summary.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
AdrExaminerNotesHistoryViewComponent,
} from '@forms/custom-sections/adr-examiner-notes-history-view/adr-examiner-notes-history-view.component';
import { AdrGuidanceNotesComponent } from '@forms/custom-sections/adr-guidance-notes/adr-guidance-notes.component';
import { AdrTankDetailsM145ViewComponent } from '@forms/custom-sections/adr-tank-details-m145-view/adr-tank-details-m145-view.component';
import {
AdrTankDetailsSubsequentInspectionsEditComponent,
} from '@forms/custom-sections/adr-tank-details-subsequent-inspections-edit/adr-tank-details-subsequent-inspections-edit.component';
Expand Down Expand Up @@ -610,6 +611,16 @@ export const AdrSummaryTemplate: FormNode = {
],
validators: [],
},
{
name: 'techRecord_adrDetails_m145Statement',
type: FormNodeTypes.CONTROL,
viewType: FormNodeViewTypes.CUSTOM,
viewComponent: AdrTankDetailsM145ViewComponent,
editType: FormNodeEditTypes.CHECKBOX,
groups: ['tank_details', 'dangerous_goods'],
hide: true,
validators: [],
},
{
name: 'techRecord_adrDetails_listStatementApplicable',
label: 'Battery List Applicable',
Expand Down
20 changes: 20 additions & 0 deletions src/app/forms/templates/general/adr.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
AdrExaminerNotesHistoryViewComponent,
} from '@forms/custom-sections/adr-examiner-notes-history-view/adr-examiner-notes-history-view.component';
import { AdrGuidanceNotesComponent } from '@forms/custom-sections/adr-guidance-notes/adr-guidance-notes.component';
import { AdrTankDetailsM145ViewComponent } from '@forms/custom-sections/adr-tank-details-m145-view/adr-tank-details-m145-view.component';
import {
AdrTankDetailsSubsequentInspectionsEditComponent,
} from '@forms/custom-sections/adr-tank-details-subsequent-inspections-edit/adr-tank-details-subsequent-inspections-edit.component';
Expand Down Expand Up @@ -608,6 +609,25 @@ export const AdrTemplate: FormNode = {
],
validators: [],
},
{
name: 'M15Subtitle',
label: 'M145',
type: FormNodeTypes.SUBTITLE,
viewType: FormNodeViewTypes.HIDDEN,
groups: ['tank_details', 'dangerous_goods'],
hide: true,
},
{
name: 'techRecord_adrDetails_m145Statement',
label: 'Yes',
type: FormNodeTypes.CONTROL,
viewType: FormNodeViewTypes.CUSTOM,
viewComponent: AdrTankDetailsM145ViewComponent,
editType: FormNodeEditTypes.CHECKBOX,
groups: ['tank_details', 'dangerous_goods'],
hide: true,
validators: [],
},
{
name: 'techRecord_adrDetails_listStatementApplicable',
label: 'Battery List Applicable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {
createVehicleRecord,
createVehicleRecordFailure,
createVehicleRecordSuccess,
generateADRCertificate,
generateADRCertificateFailure,
generateADRCertificateSuccess,
generateLetter,
generateLetterFailure,
generateLetterSuccess,
Expand All @@ -62,9 +65,6 @@ import {
updateTechRecord,
updateTechRecordFailure,
updateTechRecordSuccess,
generateADRCertificate,
generateADRCertificateFailure,
generateADRCertificateSuccess,
} from '../actions/technical-record-service.actions';
import { BatchRecords, initialBatchState, vehicleBatchCreateReducer } from './batch-create.reducer';

Expand Down Expand Up @@ -433,6 +433,7 @@ function handleClearADRDetails(state: TechnicalRecordServiceState) {
techRecord_adrDetails_applicantDetails_city: null,
techRecord_adrDetails_applicantDetails_postcode: null,
techRecord_adrDetails_memosApply: null,
techRecord_adrDetails_m145Statement: null,
techRecord_adrDetails_documents: null,
techRecord_adrDetails_listStatementApplicable: null,
techRecord_adrDetails_batteryListNumber: null,
Expand Down

0 comments on commit 2f3b427

Please sign in to comment.