-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(templates): override content + htmlelement components
This is a fix for EPR-1048 that overrides the content getter in both the "content" and "htmlelement" component classes so that the input of the interpolation is the translated string.
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { content: ContentComponent } = window.Formio.Components.components | ||
|
||
export default class Content extends ContentComponent { | ||
get content () { | ||
const submission = this.root?.submission || {} | ||
const html = this.t([`${this.component.key}.html`, this.component.html]) | ||
// console.warn('[%s] get content(): %s -> %s <-', this.component.type, this.component.html, html, this.rootValue) | ||
const content = html | ||
? this.interpolate(html, { | ||
metadata: submission.metadata || {}, | ||
submission: submission, | ||
data: this.rootValue, | ||
row: this.data | ||
}) | ||
: '' | ||
return content || '' | ||
} | ||
} |
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,17 @@ | ||
const { htmlelement: FormioHTMLElementComponent } = window.Formio.Components.components | ||
|
||
export default class HTMLElementComponent extends FormioHTMLElementComponent { | ||
get content () { | ||
const submission = this.root?.submission || {} | ||
const content = this.t([`${this.component.key}.content`, this.component.content]) | ||
// console.warn('[%s] get content(): %s -> %s <-', this.component.type, this.component.content, content, data) | ||
return content | ||
? this.interpolate(content, { | ||
metadata: submission.metadata || {}, | ||
submission, | ||
data: this.rootValue, | ||
row: this.data | ||
}) | ||
: '' | ||
} | ||
} |
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