|
|
|
@ -71,13 +71,20 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { |
|
|
|
ngOnChanges(changes: SimpleChanges): void { |
|
|
|
let reInitController = false; |
|
|
|
let initController = false; |
|
|
|
const dashboardIdChange = changes.dashboardId; |
|
|
|
const dashboardChanged = !!dashboardIdChange && !dashboardIdChange.firstChange && |
|
|
|
dashboardIdChange.currentValue !== dashboardIdChange.previousValue; |
|
|
|
for (const propName of Object.keys(changes)) { |
|
|
|
const change = changes[propName]; |
|
|
|
if (!change.firstChange && change.currentValue !== change.previousValue) { |
|
|
|
if (propName === 'statesControllerId') { |
|
|
|
this.reInit(); |
|
|
|
} else if (propName === 'states') { |
|
|
|
this.stateControllerComponent.states = this.states; |
|
|
|
if (dashboardChanged) { |
|
|
|
this.stateControllerComponent.replaceStates(this.states); |
|
|
|
} else { |
|
|
|
this.stateControllerComponent.states = this.states; |
|
|
|
} |
|
|
|
} else if (propName === 'dashboardId') { |
|
|
|
this.stateControllerComponent.dashboardId = this.dashboardId; |
|
|
|
reInitController = true; |
|
|
|
|