diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js
index 3da15def85..6d99190f5c 100644
--- a/src/plugins/condition/StyleRuleManager.js
+++ b/src/plugins/condition/StyleRuleManager.js
@@ -109,7 +109,7 @@ export default class StyleRuleManager extends EventEmitter {
} else {
if (this.currentStyle) {
Object.keys(this.currentStyle).forEach(key => {
- this.currentStyle[key] = 'transparent';
+ this.currentStyle[key] = '__no_value';
});
}
}
diff --git a/src/plugins/condition/components/inspector/ConditionalStylesView.vue b/src/plugins/condition/components/inspector/ConditionalStylesView.vue
index a960790f87..1d5e0a171f 100644
--- a/src/plugins/condition/components/inspector/ConditionalStylesView.vue
+++ b/src/plugins/condition/components/inspector/ConditionalStylesView.vue
@@ -105,7 +105,7 @@ import ConditionDescription from "@/plugins/condition/components/ConditionDescri
import ConditionError from "@/plugins/condition/components/ConditionError.vue";
import Vue from 'vue';
import PreviewAction from "@/ui/preview/PreviewAction.js";
-import {getInitialStyleForItem} from "@/plugins/condition/utils/styleUtils";
+import {getApplicableStylesForItem} from "@/plugins/condition/utils/styleUtils";
export default {
name: 'ConditionalStylesView',
@@ -130,9 +130,7 @@ export default {
}
},
destroyed() {
- if (this.stopObserving) {
- this.stopObserving();
- }
+ this.removeListeners();
},
mounted() {
this.itemId = '';
@@ -164,7 +162,8 @@ export default {
layoutItem = this.selection[0][0].context.layoutItem;
const item = this.selection[0][0].context.item;
this.canHide = true;
- if (item && this.isItemType('subobject-view', layoutItem)) {
+ if (item &&
+ (!layoutItem || (this.isItemType('subobject-view', layoutItem)))) {
domainObject = item;
} else {
domainObject = this.selection[0][1].context.item;
@@ -176,12 +175,21 @@ export default {
domainObject = this.selection[0][0].context.item;
}
this.domainObject = domainObject;
- this.initialStyles = getInitialStyleForItem(domainObject, layoutItem);
+ this.initialStyles = getApplicableStylesForItem(domainObject, layoutItem);
+ this.$nextTick(() => {
+ this.removeListeners();
+ if (this.domainObject) {
+ this.stopObserving = this.openmct.objects.observe(this.domainObject, '*', newDomainObject => this.domainObject = newDomainObject);
+ this.stopObservingItems = this.openmct.objects.observe(this.domainObject, 'configuration.items', this.updateDomainObjectItemStyles);
+ }
+ });
+ },
+ removeListeners() {
if (this.stopObserving) {
this.stopObserving();
}
- if (this.domainObject) {
- this.stopObserving = this.openmct.objects.observe(this.domainObject, '*', newDomainObject => this.domainObject = newDomainObject);
+ if (this.stopObservingItems) {
+ this.stopObservingItems();
}
},
initialize(conditionSetDomainObject) {
@@ -280,6 +288,36 @@ export default {
this.persist(domainObjectStyles);
},
+ updateDomainObjectItemStyles(newItems) {
+ //check that all items that have been styles still exist. Otherwise delete those styles
+ let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
+ let itemsToRemove = [];
+ let keys = Object.keys(domainObjectStyles);
+ keys.forEach((key) => {
+ if ((key !== 'styles') &&
+ (key !== 'staticStyle') &&
+ (key !== 'conditionSetIdentifier')) {
+ if (!(newItems.find(item => item.id === key))) {
+ itemsToRemove.push(key);
+ }
+ }
+ });
+ if (itemsToRemove.length) {
+ this.removeItemStyles(itemsToRemove, domainObjectStyles);
+ }
+ },
+ removeItemStyles(itemIds, domainObjectStyles) {
+ itemIds.forEach(itemId => {
+ if (domainObjectStyles[itemId]) {
+ domainObjectStyles[itemId] = undefined;
+ delete domainObjectStyles[this.itemId];
+ }
+ });
+ if (_.isEmpty(domainObjectStyles)) {
+ domainObjectStyles = undefined;
+ }
+ this.persist(domainObjectStyles);
+ },
initializeConditionalStyles() {
if (!this.conditions) {
this.conditions = {};
@@ -305,9 +343,15 @@ export default {
},
initializeStaticStyle(objectStyles) {
let staticStyle = objectStyles && objectStyles.staticStyle;
- this.staticStyle = staticStyle || {
- style: Object.assign({}, this.initialStyles)
- };
+ if (staticStyle) {
+ this.staticStyle = {
+ style: Object.assign({}, this.initialStyles, staticStyle.style)
+ };
+ } else {
+ this.staticStyle = {
+ style: Object.assign({}, this.initialStyles)
+ };
+ }
},
findStyleByConditionId(id) {
return this.conditionalStyles.find(conditionalStyle => conditionalStyle.conditionId === id);
diff --git a/src/plugins/condition/components/inspector/MultiSelectStylesView.vue b/src/plugins/condition/components/inspector/MultiSelectStylesView.vue
new file mode 100644
index 0000000000..2099cfe33a
--- /dev/null
+++ b/src/plugins/condition/components/inspector/MultiSelectStylesView.vue
@@ -0,0 +1,269 @@
+/*****************************************************************************
+* 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.
+*****************************************************************************/
+
+
+
+
+ Object Style
+
+
+
+ Your selection includes one or more items that use Conditional Styling. Applying a static style below will replace any Conditional Styling with the new choice.
+