Merge pull request #4820 from vvlladd28/improvement/state-controller/update-current-state

UI: Fixed not updated dashboard URL, after updated a current dashboard state
This commit is contained in:
Igor Kulikov 2021-07-02 12:42:29 +03:00 committed by GitHub
commit fc94031c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -275,15 +275,15 @@ export class EntityStateControllerComponent extends StateControllerComponent imp
}
private gotoState(stateId: string, update: boolean, openRightLayout?: boolean) {
update = update && this.dashboardCtrl.dashboardCtx.state !== stateId;
const isStateIdChanged = this.dashboardCtrl.dashboardCtx.state !== stateId;
this.dashboardCtrl.openDashboardState(stateId, openRightLayout);
this.mobileService.handleDashboardStateName(this.getStateName(this.stateObject.length - 1));
if (update) {
this.updateLocation();
this.updateLocation(isStateIdChanged);
}
}
private updateLocation() {
private updateLocation(isStateIdChanged: boolean) {
if (this.stateObject[this.stateObject.length - 1].id) {
let newState;
if (this.isDefaultState()) {
@ -291,7 +291,7 @@ export class EntityStateControllerComponent extends StateControllerComponent imp
} else {
newState = objToBase64URI(this.stateObject);
}
this.updateStateParam(newState);
this.updateStateParam(newState, !isStateIdChanged);
}
}

View File

@ -126,7 +126,7 @@ export abstract class StateControllerComponent implements IStateControllerCompon
this.rxSubscriptions.length = 0;
}
protected updateStateParam(newState: string) {
protected updateStateParam(newState: string, replaceCurrentHistoryUrl = false) {
this.currentState = newState;
if (this.syncStateWithQueryParam) {
const queryParams: Params = {state: this.currentState};
@ -137,6 +137,7 @@ export abstract class StateControllerComponent implements IStateControllerCompon
relativeTo: this.route,
queryParams,
queryParamsHandling: 'merge',
replaceUrl: replaceCurrentHistoryUrl
});
});
}