Fio 9618 render email templates using a core processor #57
Conversation
459069c to
ff6e304
Compare
ff6e304 to
d8c8216
Compare
|
There's a problem with rendering wizard forms. I'm working on it. |
af426b9 to
abf7b16
Compare
| `); | ||
| } | ||
| const document = scopeRef.emailDom.window.document; | ||
| if ( |
There was a problem hiding this comment.
do we need to handle any other conditional cases? custom logic?
There was a problem hiding this comment.
@blakekrammes almost certainly, but IIRC logic uses the same scope as simple conditionals. You could also consider using the conditionallyHidden and intentionallyHidden ephemeral state that we attach to the component.scope property, which might be a better fit here
There was a problem hiding this comment.
Interesting, from the bit of testing I've been doing, conditionally hidden components don't show up on context.data even if you provide them values in the submission object. I'm wondering if we even need to check for conditionallyHidden here.
There was a problem hiding this comment.
@blakekrammes They wouldn't show up in context.data if they were hidden, they'd show up in context.components[i].scope
There was a problem hiding this comment.
@brendanbond Ok, so if we're grabbing the component values from context.data, then we don't need to worry about checking conditionals here, right?
There was a problem hiding this comment.
Handling of conditionally and intentionally hidden components: https://github.com/formio/vm/pull/57/files#diff-4d714402b169bb5281d6d611950898ba31f5a7e034763efdbcd7dee6d101054aR70
| `); | ||
| } | ||
| const document = scopeRef.emailDom.window.document; | ||
| if ( |
There was a problem hiding this comment.
@blakekrammes almost certainly, but IIRC logic uses the same scope as simple conditionals. You could also consider using the conditionallyHidden and intentionallyHidden ephemeral state that we attach to the component.scope property, which might be a better fit here
4929c28 to
02bb864
Compare
02bb864 to
fd30165
Compare
| ); | ||
| const intentionallyHidden = component.hidden; | ||
|
|
||
| if (conditionallyHidden || intentionallyHidden) return; |
There was a problem hiding this comment.
handling of conditionally and intentionally hidden components
| return i18n.t(text, params, ...args); | ||
| }; | ||
|
|
||
| export const isLayoutComponent = (component: Component) => { |
There was a problem hiding this comment.
now detecting layout type via model types
| return modelType === 'none' || modelType === 'content'; | ||
| }; | ||
|
|
||
| export const isGridBasedComponent = (component?: Component | null) => { |
There was a problem hiding this comment.
detecting via model type now
0394a3b to
bc29f79
Compare
| // the address component stores all the data needed for rendering on the component itself | ||
| // the children (if in manual mode) do not need to be iterated over since their data is redundant | ||
| // the children are the individual manual mode address fields (address1, city, etc) | ||
| if (parent?.type === 'address') return; |
There was a problem hiding this comment.
added this code since address components in manual mode don't need to iterate over their children. context.data at the address component's data path contains everything needed for rendering. iterating over the individual manual-mode address field components is unnecessary.
address component with children:

rowValue (a.k.a. context.data{addressComponentDataPath}):

this investigation stemmed from this ticket. and, while this new email rendering returned the expected output, it was only because the code was not written to properly attach the address children to the email template. I thought it best to avoid iterating over those children entirely.
* FIO-9618: implement email rendering with jsdom * FIO-9618: Add email rendering for edit grid tagpad - move all dom insertion to renderEmailUtils - todo: nested edit grids, etc * FIO-9618: Fix pathing for nested grid-table components - Clean up other logic * FIO-9618: Add typing for email rendering via core processor - Use core Evaluator string interpolation for address formatting * FIO-9618: Fix datetime timezone handling - Handle empty values corectly for various components * FIO-9618: Use updated core version * FIO-9618: Handle wizards and doubly+ nested forms correctly * FIO-9618: Fix problems with nested grids and forms ** The initial commit was authored by Brendan, the rest and majority of code by Blake Co-authored-by: Brendan Bond <brendanbond@gmail.com>
bc29f79 to
5c79f75
Compare
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-9618
Description
What changed?
Moved email template rendering from using the renderer's
getView()functionality to rendering in a core processor using only the form and submission json.Why have you chosen this solution?
It isn't necessary to use the component class instances in the renderer to generate html for components. We were rerendering forms on the server in order to create html for them (which was error-prone and limited–– for instance, we couldn't evaluate insecure JS on the server), whereas now we just generate html based on the form json and submission data directly.
––––––––––––
Datetime component renders timezone in the email template: (this may have been added in a version since 9.3.2).
Tagpad rendering is fixed and behaves differently from how it did (notice how column headers are duplicated in 9.3.2 and how the 2nd tagpad dot is nested in the first row instead of rendered in the second):
Render multiple values for components that support it (this could be improved I think, especially for text area and address where mere comma-separation is hard to read–– probably a new table with each value as a row would be ideal):
Breaking Changes / Backwards Compatibility
n/a
Dependencies
formio/core#235
How has this PR been tested?
Automated tests (and lots of manual testing):
Checklist: