-
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-13176): VTM - Add guidance for handling documents issued cen…
…trally (#1519) * feat(cb2-13164): add issue documents centrally * feat(cb2-13164): issue documents centrally for all relevant templates * feat(cb2-13164): fix linting * feat(cb2-13164): change name from issueDocumentsCentrally to issueRequired to match BE * feat(cb2-13164): fix linting again * feat(cb2-13164): hide for group 1 * feat(cb2-13164): fix linting again again * feat(cb2-13164): set issueRequired to false for fail/abandon * feat(cb2-13176): conditionally show hint text on ADR tests only * feat(cb2-13176): fix linting * feat(cb2-13176): remove issue docs centrally from groups 2 3 4 and add to 15 and 16 * feat(cb2-13176): remove issue required from group 3 * feat(cb2-13176): remove validation for certificate number on groups 3 and 4 * feat(cb2-13176): fix linting * feat(cb2-13176): use nested shape * feat(cb2-13176): fix linting * feat(cb2-13176): ensure reasons for issue is always an array of strings
- Loading branch information
1 parent
c54e0fa
commit e5d5615
Showing
17 changed files
with
664 additions
and
410 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
src/app/forms/templates/test-records/section-templates/notes/adr-notes-section.template.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { AsyncValidatorNames } from '@forms/models/async-validators.enum'; | ||
import { ValidatorNames } from '@forms/models/validators.enum'; | ||
import { | ||
CustomFormControl, FormNode, FormNodeEditTypes, FormNodeTypes, | ||
} from '@forms/services/dynamic-form.types'; | ||
import { Store, select } from '@ngrx/store'; | ||
import { State } from '@store/index'; | ||
import { testResultInEdit } from '@store/test-records'; | ||
import { map, take, tap } from 'rxjs'; | ||
|
||
export const AdrNotesSection: FormNode = { | ||
name: 'notesSection', | ||
label: 'Notes', | ||
type: FormNodeTypes.GROUP, | ||
children: [ | ||
{ | ||
name: 'testTypes', | ||
label: 'Test Types', | ||
type: FormNodeTypes.ARRAY, | ||
children: [ | ||
{ | ||
name: '0', // it is important here that the name of the node for an ARRAY type should be an index value | ||
type: FormNodeTypes.GROUP, | ||
children: [ | ||
{ | ||
name: 'additionalNotesRecorded', | ||
label: 'Additional Notes', | ||
type: FormNodeTypes.CONTROL, | ||
value: '', | ||
editType: FormNodeEditTypes.TEXTAREA, | ||
validators: [{ name: ValidatorNames.MaxLength, args: 500 }], | ||
asyncValidators: [ | ||
// @TODO abstract into generic custom validator when used in multiple places | ||
{ | ||
name: AsyncValidatorNames.Custom, | ||
args: (control: CustomFormControl, store: Store<State>) => { | ||
return store.pipe( | ||
select(testResultInEdit), | ||
take(1), | ||
map((testResult) => testResult?.testTypes.at(0)?.centralDocs?.issueRequired), | ||
tap((issueRequired) => { | ||
control.meta.hint = issueRequired ? 'Enter a reason for issuing documents centrally' : ''; | ||
}), | ||
map(() => null), | ||
); | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; |
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.