Skip to content

Commit

Permalink
add full force reload
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Jun 1, 2021
1 parent 05c3afa commit 7f9aa31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class TemplateNavService {
params: INavQueryParams,
container: TemplateContainerComponent
) {
log(`[Query Param Change] - ${container.name}`, { ...params });
log(`[Query Param Change] - ${container.name}`, { params, container });
const { nav_child, nav_parent, popup_child, popup_parent } = params;
const { parent, name } = container;
// handle nav delegation
Expand All @@ -46,7 +46,7 @@ export class TemplateNavService {
// TODO - merge with hacks folder on merge
// TODO - CC 2021-06-01 this will require refactor after nav-actions.service merge
if (!popup_child && !popup_parent && container.template) {
await container.forceRerender();
await container.forceRerender(true);
}
}
/*****************************************************************************************************
Expand Down
20 changes: 14 additions & 6 deletions src/app/shared/components/template/template-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ export class TemplateContainerComponent implements OnInit, OnDestroy, ITemplateC
// Handle a forced rerender
// TODO - CC 2021-06-01 merge with refactored code after nav-actions.service pr merge
if (emit_value === "force_rerender") {
console.log("force rerender", this);
await this.forceRerender();
await this.forceRerender(args[1] === "full");
}
if (parent) {
// continue to emit any actions to parent where defined
Expand Down Expand Up @@ -287,19 +286,28 @@ export class TemplateContainerComponent implements OnInit, OnDestroy, ITemplateC
* e.g. in case where a nested child sets a field that needs to be shown on parent
* @param shouldProcess by default we only start processing after we have reached
* the top-most parent template, and then render down
* @param full specify whether to re-render fully as if template first load
* (including set_variable statements) or just to reprocess existing rows
*/
public async forceRerender(shouldProcess = false) {
public async forceRerender(full = false, shouldProcess = false) {
if (shouldProcess) {
await this.processRowUpdates();
console.log("[Force Rerender]", this.name, full);
if (full) {
this.renderedRows = [];
await this.renderTemplate();
} else {
await this.processRowUpdates();
}
for (const child of Object.values(this.children || {})) {
await child.forceRerender(true);
await child.forceRerender(full, true);
}
} else {
// ensure we start from the top-most parent template for rendering
if (this.parent) {
return this.parent.forceRerender();
} else {
return this.forceRerender(true);
console.log("[Force Rerender]", this);
return this.forceRerender(full, true);
}
}
}
Expand Down

0 comments on commit 7f9aa31

Please sign in to comment.