From 1f8b91654c99d2fb4b7f48f6cfa4589ab546a668 Mon Sep 17 00:00:00 2001 From: devaskim Date: Fri, 10 Feb 2023 13:26:23 +0500 Subject: [PATCH 1/2] Optionally update dashboard state when using navigate back API. --- .../states/default-state-controller.component.ts | 13 +++++++++---- .../states/entity-state-controller.component.ts | 7 +++++-- .../states/state-controller.component.ts | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts index 2e3f070a45..1abf5b8acd 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts @@ -168,10 +168,15 @@ export class DefaultStateControllerComponent extends StateControllerComponent im } } - public navigatePrevState(index: number): void { - if (index < this.stateObject.length - 1) { - this.stateObject.splice(index + 1, this.stateObject.length - index - 1); - this.gotoState(this.stateObject[this.stateObject.length - 1].id, true); + public navigatePrevState(index: number, params?: StateParams): void { + let lastIndex: number = this.stateObject.length - 1; + if (index < lastIndex) { + this.stateObject.splice(index + 1, lastIndex - 1); + lastIndex = this.stateObject.length - 1; + if (params) { + this.stateObject[lastIndex].params = params; + } + this.gotoState(this.stateObject[lastIndex].id, true); } } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/entity-state-controller.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/entity-state-controller.component.ts index 0e2e3350d0..776363ed6b 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/entity-state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/entity-state-controller.component.ts @@ -195,11 +195,14 @@ export class EntityStateControllerComponent extends StateControllerComponent imp } } - public navigatePrevState(index: number): void { + public navigatePrevState(index: number, params?: StateParams): void { if (index < this.stateObject.length - 1) { this.stateObject.splice(index + 1, this.stateObject.length - index - 1); this.selectedStateIndex = this.stateObject.length - 1; - this.gotoState(this.stateObject[this.stateObject.length - 1].id, true); + if (params) { + this.stateObject[this.selectedStateIndex].params = params; + } + this.gotoState(this.stateObject[this.selectedStateIndex].id, true); } } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts index 07ac550f13..6a9991209f 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts @@ -199,7 +199,7 @@ export abstract class StateControllerComponent implements IStateControllerCompon public abstract getStateParamsByStateId(stateId: string): StateParams; - public abstract navigatePrevState(index: number): void; + public abstract navigatePrevState(index: number, params?: StateParams): void; public abstract openState(id: string, params?: StateParams, openRightLayout?: boolean): void; From f3b538d6a963a3819943f3d44519908fef3d6b30 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 30 Mar 2023 12:21:20 +0300 Subject: [PATCH 2/2] UI: Fixed navigatePrevState and updated help template --- ui-ngx/src/app/core/api/widget-api.models.ts | 2 +- .../states/default-state-controller.component.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui-ngx/src/app/core/api/widget-api.models.ts b/ui-ngx/src/app/core/api/widget-api.models.ts index c6e00ab882..115bf6e222 100644 --- a/ui-ngx/src/app/core/api/widget-api.models.ts +++ b/ui-ngx/src/app/core/api/widget-api.models.ts @@ -160,7 +160,7 @@ export interface IStateController { openRightLayout(): void; preserveState(): void; cleanupPreservedStates(): void; - navigatePrevState(index: number): void; + navigatePrevState(index: number, params?: StateParams): void; getStateId(): string; getStateIndex(): number; getStateIdAtIndex(index: number): string; diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts index 1abf5b8acd..dcf7c70e00 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/default-state-controller.component.ts @@ -169,14 +169,14 @@ export class DefaultStateControllerComponent extends StateControllerComponent im } public navigatePrevState(index: number, params?: StateParams): void { - let lastIndex: number = this.stateObject.length - 1; - if (index < lastIndex) { - this.stateObject.splice(index + 1, lastIndex - 1); - lastIndex = this.stateObject.length - 1; + const lastStateIndex = this.stateObject.length - 1; + if (index < lastStateIndex) { + this.stateObject.splice(index + 1, lastStateIndex - index); + const selectedStateIndex = this.stateObject.length - 1; if (params) { - this.stateObject[lastIndex].params = params; + this.stateObject[selectedStateIndex].params = params; } - this.gotoState(this.stateObject[lastIndex].id, true); + this.gotoState(this.stateObject[selectedStateIndex].id, true); } }