From f7c58f9b71cb279c8bf28c42fbd5e8f7ae8b186e Mon Sep 17 00:00:00 2001 From: pbardy2000 <146740183+pbardy2000@users.noreply.github.com> Date: Wed, 14 Aug 2024 07:49:49 +0100 Subject: [PATCH] fix(cb2-13164): add issue docs centrally to TIR test types (#1543) * fix(cb2-13164): add issue docs centrally to TIR test types * fix(cb2-13164): fix linting --- ...gency-test-section-group5And13.template.ts | 36 ++++++++++++++++--- .../test/test-section-group5And13.template.ts | 31 +++++++++++++++- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/app/forms/templates/test-records/section-templates/test/contingency/contingency-test-section-group5And13.template.ts b/src/app/forms/templates/test-records/section-templates/test/contingency/contingency-test-section-group5And13.template.ts index 9cceae04f5..757e51a7e5 100644 --- a/src/app/forms/templates/test-records/section-templates/test/contingency/contingency-test-section-group5And13.template.ts +++ b/src/app/forms/templates/test-records/section-templates/test/contingency/contingency-test-section-group5And13.template.ts @@ -52,9 +52,37 @@ export const ContingencyTestSectionGroup5And13: FormNode = { { value: 'fail', label: 'Fail' }, ], asyncValidators: [{ name: AsyncValidatorNames.ResultDependantOnCustomDefects }], - validators: [{ name: ValidatorNames.HideIfNotEqual, args: { sibling: 'certificateNumber', value: 'pass' } }], + validators: [ + { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'certificateNumber', value: 'pass' } }, + { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'centralDocs', value: 'pass' } }, + ], type: FormNodeTypes.CONTROL, }, + { + name: 'centralDocs', + type: FormNodeTypes.GROUP, + children: [ + { + name: 'issueRequired', + type: FormNodeTypes.CONTROL, + label: 'Issue documents centrally', + editType: FormNodeEditTypes.RADIO, + value: false, + options: [ + { value: true, label: 'Yes' }, + { value: false, label: 'No' }, + ], + validators: [{ name: ValidatorNames.HideIfParentSiblingEqual, args: { sibling: 'certificateNumber', value: true } }], + }, + { + name: 'reasonsForIssue', + type: FormNodeTypes.CONTROL, + viewType: FormNodeViewTypes.HIDDEN, + editType: FormNodeEditTypes.HIDDEN, + value: [], + }, + ], + }, { name: 'testTypeName', label: 'Description', @@ -85,10 +113,8 @@ export const ContingencyTestSectionGroup5And13: FormNode = { type: FormNodeTypes.CONTROL, validators: [ { name: ValidatorNames.Alphanumeric }, - { - name: ValidatorNames.RequiredIfEquals, - args: { sibling: 'testResult', value: ['pass'] }, - }, + // Make required if test result is pass/prs, but issue documents centrally is false + { name: ValidatorNames.IssueRequired }, ], required: true, value: null, diff --git a/src/app/forms/templates/test-records/section-templates/test/test-section-group5And13.template.ts b/src/app/forms/templates/test-records/section-templates/test/test-section-group5And13.template.ts index 1fae34d9e0..7263f2b07a 100644 --- a/src/app/forms/templates/test-records/section-templates/test/test-section-group5And13.template.ts +++ b/src/app/forms/templates/test-records/section-templates/test/test-section-group5And13.template.ts @@ -60,10 +60,36 @@ export const TestSectionGroup5And13: FormNode = { { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'reasonForAbandoning', value: 'abandoned' } }, { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'additionalCommentsForAbandon', value: 'abandoned' } }, { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'certificateNumber', value: ['pass', 'prs', 'abandoned'] } }, + { name: ValidatorNames.HideIfNotEqual, args: { sibling: 'centralDocs', value: ['pass', 'prs'] } }, ], asyncValidators: [{ name: AsyncValidatorNames.ResultDependantOnCustomDefects }], type: FormNodeTypes.CONTROL, }, + { + name: 'centralDocs', + type: FormNodeTypes.GROUP, + children: [ + { + name: 'issueRequired', + type: FormNodeTypes.CONTROL, + label: 'Issue documents centrally', + editType: FormNodeEditTypes.RADIO, + value: false, + options: [ + { value: true, label: 'Yes' }, + { value: false, label: 'No' }, + ], + validators: [{ name: ValidatorNames.HideIfParentSiblingEqual, args: { sibling: 'certificateNumber', value: true } }], + }, + { + name: 'reasonsForIssue', + type: FormNodeTypes.CONTROL, + viewType: FormNodeViewTypes.HIDDEN, + editType: FormNodeEditTypes.HIDDEN, + value: [], + }, + ], + }, { name: 'testTypeName', label: 'Description', @@ -78,7 +104,10 @@ export const TestSectionGroup5And13: FormNode = { type: FormNodeTypes.CONTROL, viewType: FormNodeViewTypes.HIDDEN, editType: FormNodeEditTypes.HIDDEN, - required: true, + validators: [ + // Make required if test result is pass/prs, but issue documents centrally is false + { name: ValidatorNames.IssueRequired }, + ], value: null, }, {