-
Notifications
You must be signed in to change notification settings - Fork 43
minor: SummaryViewModel outputs #1264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| outputConfiguration: NotifyOutputConfiguration, | ||
| state: FormSubmissionState | ||
| ): NotifyModel { | ||
| ): TNotifyModel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting clashes with NotifyModel the function and NotifyModel the data type, so I've renamed it to TNotifyModel
| item.isRepeatable ? (index = i) : 0; | ||
| const fields = [detailItemToField(item)]; | ||
| function createToFieldsMap(state: FormSubmissionState) { | ||
| return function (component: FormComponent | SelectionControlField): Field { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be FormComponent | SelectionControlField | ComponentCollection? Just thinking that below you're looking for a children collection, so wasn't sure whether that was related to ComponentCollection or whether it's somewhere in the SelectionControlField that I couldn't see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm specifically looking for what would be conditionally revealed components, which would live on SelectionControlFields. This test should fail every time because SelectionControlField.items.childrenCollection?.formItems doesn't exist anymore
Just double checked that this doesn't clash with component collection implementation though. I think this would only be an issue for date parts fields, which is first passed through as a FormComponent (subclass). We're just retrieving from state directly here, not via the component.
lmk if you think I've missed something though 🫡
Description
This is a refactor of SummaryViewModel and the outputs it creates.
Previously, SummaryViewModel was created to reduce the size of SummaryPageController and make the code more readable. Much of SummaryPageController's constructor code was just moved to SummaryViewModel, including code which created
outputs.It was easiest to generate outputs (specifically the webhook output) from the SummaryViewModel, since it was a "flattened" form of the state data, which included the "human readable" titles of fields. However, some additional iteration/nested loops still happened between SummaryViewModel.details (i.e. what is needed to render the summary page) and pages to "fill in the gaps".
This has caused tight coupling between SummaryViewModel.details and WebhookModel. The tight coupling makes #1263 (#798) too big of a PR and introduce more loops to fill the gaps/try to determine iterations (as exhibited by the current repeated code!).
A further refactor of SummaryViewModel is necessary, so that SummaryViewModel is only responsible for parsing data for the purposes of rendering the page.
Outputsclass, which encapsulatesOutputcreationgetRelevantPagestoFormModelWebhookModelnow only relies onFormModelandstateType of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce
the testing if necessary.
Checklist: