From 53440c31d5c823f024961dabe379d4a403f3b14c Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Thu, 26 Mar 2020 13:12:22 -0700 Subject: [PATCH] Handles remove telemetry from condition set - this resets criterion properties (#2791) Handles remove condition from a condition set that's being used in a conditional style. Fixes a small bug with stye rule manager request lad results --- .../ConditionSetTelemetryProvider.js | 8 +++++--- src/plugins/condition/StyleRuleManager.js | 8 ++++++-- .../condition/components/Condition.vue | 2 +- .../condition/components/Criterion.vue | 19 +++++++++++++++++++ .../inspector/ConditionalStylesView.vue | 6 +++++- .../condition/criterion/TelemetryCriterion.js | 5 ++++- 6 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/plugins/condition/ConditionSetTelemetryProvider.js b/src/plugins/condition/ConditionSetTelemetryProvider.js index 052406be0d..53d47301a4 100644 --- a/src/plugins/condition/ConditionSetTelemetryProvider.js +++ b/src/plugins/condition/ConditionSetTelemetryProvider.js @@ -77,8 +77,10 @@ export default class ConditionSetTelemetryProvider { * can be called manually for views that only request but do not subscribe to data */ destroyConditionManager(id) { - this.conditionManagerPool[id].off('conditionSetResultUpdated'); - this.conditionManagerPool[id].destroy(); - delete this.conditionManagerPool[id]; + if (this.conditionManagerPool[id]) { + this.conditionManagerPool[id].off('conditionSetResultUpdated'); + this.conditionManagerPool[id].destroy(); + delete this.conditionManagerPool[id]; + } } } diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js index c09a291090..3da15def85 100644 --- a/src/plugins/condition/StyleRuleManager.js +++ b/src/plugins/condition/StyleRuleManager.js @@ -49,7 +49,11 @@ export default class StyleRuleManager extends EventEmitter { } this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => { this.openmct.telemetry.request(conditionSetDomainObject) - .then(output => this.handleConditionSetResultUpdated(output)); + .then(output => { + if (output && output.length) { + this.handleConditionSetResultUpdated(output[0]); + } + }); this.stopProvidingTelemetry = this.openmct.telemetry.subscribe(conditionSetDomainObject, output => this.handleConditionSetResultUpdated(output)); }); } @@ -60,7 +64,7 @@ export default class StyleRuleManager extends EventEmitter { this.destroy(); } else { let isNewConditionSet = !this.conditionSetIdentifier || - this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier); + !this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier); this.initialize(styleConfiguration); //Only resubscribe if the conditionSet has changed. if (isNewConditionSet) { diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue index cab86f2e5f..77d5a83a50 100644 --- a/src/plugins/condition/components/Condition.vue +++ b/src/plugins/condition/components/Condition.vue @@ -119,7 +119,7 @@ -