From 7f9aa31bd92cc511e9672435be29e61f60564978 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Tue, 1 Jun 2021 14:32:09 -0700 Subject: [PATCH] add full force reload --- .../template/services/template-nav.service.ts | 4 ++-- .../template/template-container.component.ts | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/app/shared/components/template/services/template-nav.service.ts b/src/app/shared/components/template/services/template-nav.service.ts index d95e14988..020acd474 100644 --- a/src/app/shared/components/template/services/template-nav.service.ts +++ b/src/app/shared/components/template/services/template-nav.service.ts @@ -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 @@ -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); } } /***************************************************************************************************** diff --git a/src/app/shared/components/template/template-container.component.ts b/src/app/shared/components/template/template-container.component.ts index e1bcb00d4..78294e8f6 100644 --- a/src/app/shared/components/template/template-container.component.ts +++ b/src/app/shared/components/template/template-container.component.ts @@ -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 @@ -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); } } }