Skip to content

Commit

Permalink
Merge pull request #2135 from IDEMSInternational/refactor/popup-nav-d…
Browse files Browse the repository at this point in the history
…ismiss

refactor!: popup-nav-dismiss
  • Loading branch information
esmeetewinkel authored Nov 27, 2023
2 parents 3dc65f7 + c982229 commit 2123563
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/data-models/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ export namespace FlowTypes {
"audio_end",
"audio_play",
"changed",
"close_pop_up",
"emit",
"feedback",
"go_to",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class TemplateNavService extends SyncServiceBase {
/*****************************************************************************************************
* Nav Actions
****************************************************************************************************/
public handleNavAction(action: FlowTypes.TemplateRowAction) {
public async handleNavAction(action: FlowTypes.TemplateRowAction) {
// TODO: Find more elegant way to get current root level template name
const parentName = location.pathname.replace("/template/", "");
const [templatename, key, value] = action.args;
Expand All @@ -85,9 +85,25 @@ export class TemplateNavService extends SyncServiceBase {
// handle direct page or template navigation
const navTarget = templatename.startsWith("/") ? [templatename] : ["template", templatename];

// If "dismiss_on_return" is set to true for the go_to action, dismiss the current popup before navigating away
if (key === "dismiss_on_return" && parseBoolean(value)) {
history.replaceState({}, "", location.pathname);
// If "dismiss_pop_up" is set to true for the go_to action, dismiss the current popup before navigating away
if (key === "dismiss_pop_up" && parseBoolean(value)) {
const { popup_child } = this.route.snapshot.queryParams;
if (popup_child) {
const popupDismissParams: INavQueryParams = {
popup_child: null,
popup_parent: null,
popup_parent_triggered_by: null,
};
// alter route history so that on back-nav popup will not be present
await this.router.navigate([], {
relativeTo: this.route,
queryParams: popupDismissParams,
queryParamsHandling: "merge",
replaceUrl: true,
});
// Dismiss open popup (without await to allow rest of nav to proceed await)
this.dismissPopup(popup_child);
}
}
return this.router.navigate(navTarget, {
queryParams,
Expand Down

0 comments on commit 2123563

Please sign in to comment.