From d5480e7524cc4ac0700e06fe1acfdd6bd28de695 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Mon, 1 Jun 2020 12:40:40 -0700 Subject: [PATCH] Multiple item conditional styles (#3017) Conditional Styles for multiple items #3076 * Preview condition styles on selecting that condition or one of it's styles Do not evaluate conditional styles in edit mode * Conditions styling tweaked - Condition match `is-current` styling for browse and edit modes; - Disallowed pointer events on Conditions to prevent selection in Inspector when not editing; * Highlight current condition in conditionSet view * Addresses review comments. * Condition matching highlighting tweaked - Enable match highlighting during Editing; - Tweaks to `is-current` styling; * Don't reset the callback on destroy * Combine multiple and single selection styling of objects * Fix issue with applying styles in edit mode * Fix item styles bug * Remove comment * Adds back visibility toggle * Set isEditing on initialization. * Addresses review comments - removes use of lodash. Co-authored-by: charlesh88 Co-authored-by: Deep Tailor --- src/plugins/condition/StyleRuleManager.js | 2 +- .../components/inspector/StylesView.vue | 601 ++++++++++++++++++ src/plugins/condition/utils/styleUtils.js | 15 +- src/ui/inspector/StylesInspectorView.vue | 9 +- 4 files changed, 619 insertions(+), 8 deletions(-) create mode 100644 src/plugins/condition/components/inspector/StylesView.vue diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js index fb585455cb..6fe7b38c37 100644 --- a/src/plugins/condition/StyleRuleManager.js +++ b/src/plugins/condition/StyleRuleManager.js @@ -29,6 +29,7 @@ export default class StyleRuleManager extends EventEmitter { this.callback = callback; if (suppressSubscriptionOnEdit) { this.openmct.editor.on('isEditing', this.toggleSubscription.bind(this)); + this.isEditing = this.openmct.editor.editing; } if (styleConfiguration) { this.initialize(styleConfiguration); @@ -156,7 +157,6 @@ export default class StyleRuleManager extends EventEmitter { } delete this.stopProvidingTelemetry; this.conditionSetIdentifier = undefined; - this.isEditing = undefined; } } diff --git a/src/plugins/condition/components/inspector/StylesView.vue b/src/plugins/condition/components/inspector/StylesView.vue new file mode 100644 index 0000000000..dd783cda8a --- /dev/null +++ b/src/plugins/condition/components/inspector/StylesView.vue @@ -0,0 +1,601 @@ +/***************************************************************************** +* Open MCT, Copyright (c) 2014-2020, United States Government +* as represented by the Administrator of the National Aeronautics and Space +* Administration. All rights reserved. +* +* Open MCT is licensed under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0. +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +* +* Open MCT includes source code licensed under additional open source +* licenses. See the Open Source Licenses file (LICENSES.md) included with +* this source code distribution or the Licensing information page available +* at runtime from the About dialog for additional information. +*****************************************************************************/ + + + + diff --git a/src/plugins/condition/utils/styleUtils.js b/src/plugins/condition/utils/styleUtils.js index 24bf82a1d7..03a83d9c2f 100644 --- a/src/plugins/condition/utils/styleUtils.js +++ b/src/plugins/condition/utils/styleUtils.js @@ -124,12 +124,25 @@ export const getConditionalStyleForItem = (domainObject, id) => { if (domainObjectStyles[id] && domainObjectStyles[id].conditionSetIdentifier) { return domainObjectStyles[id].styles; } - } else if (domainObjectStyles.staticStyle) { + } else if (domainObjectStyles.conditionSetIdentifier) { return domainObjectStyles.styles; } } }; +export const getConditionSetIdentifierForItem = (domainObject, id) => { + let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles; + if (domainObjectStyles) { + if (id) { + if (domainObjectStyles[id] && domainObjectStyles[id].conditionSetIdentifier) { + return domainObjectStyles[id].conditionSetIdentifier; + } + } else if (domainObjectStyles.conditionSetIdentifier) { + return domainObjectStyles.conditionSetIdentifier; + } + } +}; + //Returns either existing static styles or uses SVG defaults if available export const getApplicableStylesForItem = (domainObject, item) => { const type = item && item.type; diff --git a/src/ui/inspector/StylesInspectorView.vue b/src/ui/inspector/StylesInspectorView.vue index 80aa8d8328..9bf2eba1db 100644 --- a/src/ui/inspector/StylesInspectorView.vue +++ b/src/ui/inspector/StylesInspectorView.vue @@ -25,8 +25,7 @@