From e174f075df52a060e93f11e396d679958949112b Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Mon, 20 Mar 2023 17:06:10 -0700 Subject: [PATCH] Don't initialize the selected condition style when a view is loaded (#6478) * Don't initialize the selected condition style when a view is loaded * Ensure selection of styles in Edit mode works as expected. When out of edit mode, only a computed style should be chosen to display. --- src/plugins/condition/StyleRuleManager.js | 10 ++++++++-- .../condition/components/inspector/StylesView.vue | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js index 757e9e741e..2e2270ef65 100644 --- a/src/plugins/condition/StyleRuleManager.js +++ b/src/plugins/condition/StyleRuleManager.js @@ -35,7 +35,9 @@ export default class StyleRuleManager extends EventEmitter { } if (styleConfiguration) { - this.initialize(styleConfiguration); + // We don't set the selectedConditionId here because we want condition set computation to happen before we apply any selected style + const styleConfigurationWithNoSelection = Object.assign(styleConfiguration, {selectedConditionId: ''}); + this.initialize(styleConfigurationWithNoSelection); if (styleConfiguration.conditionSetIdentifier) { this.openmct.time.on("bounds", this.refreshData); this.subscribeToConditionSet(); @@ -57,14 +59,18 @@ export default class StyleRuleManager extends EventEmitter { this.applySelectedConditionStyle(); } } else if (this.conditionSetIdentifier) { + //reset the selected style and let the condition set output determine what it should be + this.selectedConditionId = undefined; + this.currentStyle = undefined; + this.updateDomainObjectStyle(); this.subscribeToConditionSet(); } } initialize(styleConfiguration) { this.conditionSetIdentifier = styleConfiguration.conditionSetIdentifier; - this.staticStyle = styleConfiguration.staticStyle; this.selectedConditionId = styleConfiguration.selectedConditionId; + this.staticStyle = styleConfiguration.staticStyle; this.defaultConditionId = styleConfiguration.defaultConditionId; this.updateConditionStylesMap(styleConfiguration.styles || []); } diff --git a/src/plugins/condition/components/inspector/StylesView.vue b/src/plugins/condition/components/inspector/StylesView.vue index 6ced26b456..9556f178d4 100644 --- a/src/plugins/condition/components/inspector/StylesView.vue +++ b/src/plugins/condition/components/inspector/StylesView.vue @@ -307,6 +307,8 @@ export default { delete this.stopProvidingTelemetry; } } else { + //reset the selectedConditionID so that the condition set computation can drive it. + this.applySelectedConditionStyle(''); this.subscribeToConditionSet(); } },