diff --git a/src/plugins/conditionWidget/conditionWidgetStylesInterceptor.js b/src/plugins/conditionWidget/conditionWidgetStylesInterceptor.js index c7318982ea..a6e29ff4eb 100644 --- a/src/plugins/conditionWidget/conditionWidgetStylesInterceptor.js +++ b/src/plugins/conditionWidget/conditionWidgetStylesInterceptor.js @@ -26,9 +26,11 @@ export default function conditionWidgetStylesInterceptor(openmct) { return identifier.key === 'conditionWidget' && !domainObject.configuration?.objectStyles; }, invoke: (identifier, domainObject) => { - domainObject.configuration = { - objectStyles: {} - }; + if (!domainObject.configuration) { + domainObject.configuration = {}; + } + + domainObject.configuration.objectStyles = {}; openmct.objects.save(domainObject); diff --git a/src/plugins/plot/PlotView.vue b/src/plugins/plot/PlotView.vue index 901c3b34e5..34eac98331 100644 --- a/src/plugins/plot/PlotView.vue +++ b/src/plugins/plot/PlotView.vue @@ -173,15 +173,6 @@ export default { created() { eventHelpers.extend(this); this.imageExporter = new ImageExporter(this.openmct); - - // Initialize objectStyles for overlay plot if it doesn't exist - if ( - this.domainObject.type === 'telemetry.plot.overlay' && - !this.domainObject.configuration.objectStyles - ) { - this.domainObject.configuration.objectStyles = {}; - } - this.loadComposition(); this.setupClockChangedEvent((domainObject) => { this.triggerUnsubscribeFromStaleness(domainObject); diff --git a/src/plugins/plot/overlayPlot/overlayPlotStylesInterceptor.js b/src/plugins/plot/overlayPlot/overlayPlotStylesInterceptor.js new file mode 100644 index 0000000000..88a56e5f6a --- /dev/null +++ b/src/plugins/plot/overlayPlot/overlayPlotStylesInterceptor.js @@ -0,0 +1,43 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2024, 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. + *****************************************************************************/ + +export default function overlayPlotStylesInterceptor(openmct) { + return { + appliesTo: (identifier, domainObject) => { + return ( + identifier.key === 'telemetry.plot.overlay' && !domainObject.configuration?.objectStyles + ); + }, + invoke: (identifier, domainObject) => { + if (!domainObject.configuration) { + domainObject.configuration = {}; + } + + domainObject.configuration.objectStyles = {}; + + openmct.objects.save(domainObject); + + return domainObject; + }, + priority: openmct.priority.DEFAULT + }; +} diff --git a/src/plugins/plot/plugin.js b/src/plugins/plot/plugin.js index e270ffbec3..ac3fbd047e 100644 --- a/src/plugins/plot/plugin.js +++ b/src/plugins/plot/plugin.js @@ -23,6 +23,7 @@ import PlotViewActions from './actions/ViewActions.js'; import PlotsInspectorViewProvider from './inspector/PlotsInspectorViewProvider.js'; import StackedPlotsInspectorViewProvider from './inspector/StackedPlotsInspectorViewProvider.js'; import OverlayPlotCompositionPolicy from './overlayPlot/OverlayPlotCompositionPolicy.js'; +import overlayPlotStylesInterceptor from './overlayPlot/overlayPlotStylesInterceptor.js'; import OverlayPlotViewProvider from './overlayPlot/OverlayPlotViewProvider.js'; import PlotViewProvider from './PlotViewProvider.js'; import StackedPlotCompositionPolicy from './stackedPlot/StackedPlotCompositionPolicy.js'; @@ -31,6 +32,8 @@ import StackedPlotViewProvider from './stackedPlot/StackedPlotViewProvider.js'; export default function () { return function install(openmct) { + openmct.objects.addGetInterceptor(overlayPlotStylesInterceptor(openmct)); + openmct.types.addType('telemetry.plot.overlay', { key: 'telemetry.plot.overlay', name: 'Overlay Plot',