-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: data items nested templates #2639
Changes from all commits
a267446
16903c8
6ff0da8
fd346d6
462cebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,8 @@ export class TemplateComponent implements OnInit, AfterContentInit, ITemplateRow | |
this._row = row; | ||
if (this.componentRef) { | ||
log("[Component Update]", row.name, row); | ||
this.componentRef.instance.row = row; | ||
this.componentRef.setInput("row", row); | ||
this.hackForceReprocessNestedTemplate(); | ||
} else { | ||
log("[Component Create]", row.name, row); | ||
} | ||
|
@@ -130,7 +131,7 @@ export class TemplateComponent implements OnInit, AfterContentInit, ITemplateRow | |
// Depending on row type, either prepare instantiation of a nested template or a display component | ||
switch (row.type) { | ||
case "template": | ||
return this.renderTemplateComponent(TemplateContainerComponent, row); | ||
return this.renderTemplateComponent(row); | ||
default: | ||
const displayComponent = TEMPLATE_COMPONENT_MAPPING[row.type]; | ||
if (displayComponent) { | ||
|
@@ -145,15 +146,12 @@ export class TemplateComponent implements OnInit, AfterContentInit, ITemplateRow | |
} | ||
|
||
/** Create and render a nested template component */ | ||
private renderTemplateComponent( | ||
component: typeof TemplateContainerComponent, | ||
row: FlowTypes.TemplateRow | ||
) { | ||
private renderTemplateComponent(row: FlowTypes.TemplateRow) { | ||
const viewContainerRef = this.tmplComponentHost.viewContainerRef; | ||
const componentRef = viewContainerRef.createComponent(component); | ||
const componentRef = viewContainerRef.createComponent(TemplateContainerComponent); | ||
// assign input variables (note template name taken from the row's value column) | ||
componentRef.instance.parent = this.parent; | ||
componentRef.instance.row = row; | ||
componentRef.setInput("row", row); | ||
componentRef.instance.name = row.name; | ||
// assign templatename input using signal | ||
componentRef.setInput("templatename", row.value); | ||
|
@@ -169,4 +167,25 @@ export class TemplateComponent implements OnInit, AfterContentInit, ITemplateRow | |
componentRef.instance.row = row; | ||
this.componentRef = componentRef; | ||
} | ||
|
||
/** | ||
* If the current template is generated as a child of data_items then updates to | ||
* parent variables will not propagate down. Force reprocessing to workaround | ||
* See issue https://github.com/IDEMSInternational/open-app-builder/issues/2636 | ||
*/ | ||
private async hackForceReprocessNestedTemplate() { | ||
if (this._row.type === "template") { | ||
const componentRef = this.componentRef as ComponentRef<TemplateContainerComponent>; | ||
if (componentRef.instance.parent) { | ||
// HACK - if parent template changes name of nested child template instance fully | ||
// recreate the template container | ||
if ((componentRef.instance.templatename(), this._row.value)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This use of the comma operator isn't clear to me. I'm supposing that the signal value is being accessed here to ensure that any reactive side-effects (including ultimately updating If that's right, might it be clearer to access the signal outside of the if statement and add a comment to explain the dependency being established? I think my confusion is mostly down to unfamiliarity with the comma operator, I can see how this could be an established pattern for making sure the first expression has evaluated and any side-effects propagated before evaluating the first expression, but I wouldn't have expected this to be required when using signals. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, that was meant to be a So I think for now we'll just have to stick with the heavier condition to always fully recreate when the parent of a child template changes (first part of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in #2647 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for the visual-tests failing, I see this happening generally example failed action [1220/175851.640539:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see
https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. so I think I'll give it a couple days to see if it's an issue resolved within github actions (could be an issue related to internal action runner updates), before looking more closely and trying to update the action/dependencies |
||
this.componentRef.destroy(); | ||
this.renderTemplateComponent(this._row); | ||
// TODO - test better ways to manage from container, confirming test cases from | ||
// https://github.com/IDEMSInternational/open-app-builder/issues/2636 | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
Might benefit from an explanatory comment on why
data_items
anditems
rows are excludedThere 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.
Updated in #2647