Commit 6b53e84c84eabd8a929abd56313e7b763fe2150f

Authored by Igor Kulikov
Committed by GitHub
2 parents 8e78589b f5f6d4b9

Merge pull request #3273 from vvlladd28/bug/update/state-id

[3.0] Fix update state id value
... ... @@ -35,7 +35,7 @@ import { fromEvent, merge } from 'rxjs';
35 35 import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
36 36 import { TranslateService } from '@ngx-translate/core';
37 37 import { DialogService } from '@core/services/dialog.service';
38   -import { deepClone } from '@core/utils';
  38 +import { deepClone, isUndefined } from '@core/utils';
39 39 import {
40 40 DashboardStateDialogComponent,
41 41 DashboardStateDialogData
... ... @@ -198,8 +198,9 @@ export class ManageDashboardStatesDialogComponent extends
198 198 root: state.root,
199 199 layouts: state.layouts
200 200 };
201   - if (prevStateId) {
202   - this.states[prevStateId] = newState;
  201 + if (prevStateId && prevStateId !== state.id) {
  202 + delete this.states[prevStateId];
  203 + this.states[state.id] = newState;
203 204 } else {
204 205 this.states[state.id] = newState;
205 206 }
... ... @@ -210,6 +211,19 @@ export class ManageDashboardStatesDialogComponent extends
210 211 otherState.root = false;
211 212 }
212 213 }
  214 + } else {
  215 + let rootFound = false;
  216 + for (const id of Object.keys(this.states)) {
  217 + const otherState = this.states[id];
  218 + if (otherState.root) {
  219 + rootFound = true;
  220 + break;
  221 + }
  222 + }
  223 + if (!rootFound) {
  224 + const firstStateId = Object.keys(this.states)[0];
  225 + this.states[firstStateId].root = true;
  226 + }
213 227 }
214 228 this.onStatesUpdated();
215 229 }
... ...