From 56326ad6d11ca1408c516d584c5e95aaf79e88db Mon Sep 17 00:00:00 2001 From: Jamie V Date: Fri, 4 Apr 2025 13:03:43 -0700 Subject: [PATCH] added remaining interceptors and removed in-component modification, removed debug code --- .../components/DisplayLayout.vue | 5 --- .../displayLayoutStylesInterceptor.js | 40 +++++++++++++++++++ src/plugins/displayLayout/plugin.js | 3 +- .../components/FlexibleLayout.vue | 5 --- .../flexibleLayoutStylesInterceptor.js | 40 +++++++++++++++++++ src/plugins/flexibleLayout/plugin.js | 2 + src/plugins/gauge/GaugePlugin.js | 3 +- .../gauge/components/GaugeComponent.vue | 5 --- src/plugins/gauge/gaugeStylesInterceptor.js | 40 +++++++++++++++++++ .../inspectorViews/elements/ElementsPool.vue | 1 - 10 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 src/plugins/displayLayout/displayLayoutStylesInterceptor.js create mode 100644 src/plugins/flexibleLayout/flexibleLayoutStylesInterceptor.js create mode 100644 src/plugins/gauge/gaugeStylesInterceptor.js diff --git a/src/plugins/displayLayout/components/DisplayLayout.vue b/src/plugins/displayLayout/components/DisplayLayout.vue index 7175e568d5..fd5bdb3a80 100644 --- a/src/plugins/displayLayout/components/DisplayLayout.vue +++ b/src/plugins/displayLayout/components/DisplayLayout.vue @@ -226,11 +226,6 @@ export default { this.composition.load(); this.gridDimensions = [this.$el.offsetWidth, this.$el.scrollHeight]; - // Initialize objectStyles if it doesn't exist for older versions - if (!this.domainObject.configuration.objectStyles) { - this.domainObject.configuration.objectStyles = {}; - } - this.unObserveItems = this.openmct.objects.observe( this.domainObject, 'configuration.items', diff --git a/src/plugins/displayLayout/displayLayoutStylesInterceptor.js b/src/plugins/displayLayout/displayLayoutStylesInterceptor.js new file mode 100644 index 0000000000..b9bfb5216b --- /dev/null +++ b/src/plugins/displayLayout/displayLayoutStylesInterceptor.js @@ -0,0 +1,40 @@ +/***************************************************************************** + * 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 displayLayoutStylesInterceptor(openmct) { + return { + appliesTo: (identifier, domainObject) => { + return domainObject?.type === 'layout'; + }, + invoke: (identifier, domainObject) => { + if (!domainObject.configuration) { + domainObject.configuration = {}; + } + + if (!domainObject.configuration.objectStyles) { + domainObject.configuration.objectStyles = {}; + } + + return domainObject; + } + }; +} diff --git a/src/plugins/displayLayout/plugin.js b/src/plugins/displayLayout/plugin.js index 67ba40bd61..5c83f4d172 100644 --- a/src/plugins/displayLayout/plugin.js +++ b/src/plugins/displayLayout/plugin.js @@ -25,10 +25,10 @@ import mount from 'utils/mount'; import CopyToClipboardAction from './actions/CopyToClipboardAction.js'; import AlphaNumericFormatViewProvider from './AlphanumericFormatViewProvider.js'; import DisplayLayout from './components/DisplayLayout.vue'; +import displayLayoutStylesInterceptor from './displayLayoutStylesInterceptor.js'; import DisplayLayoutToolbar from './DisplayLayoutToolbar.js'; import DisplayLayoutType from './DisplayLayoutType.js'; import DisplayLayoutDrawingObjectTypes from './DrawingObjectTypes.js'; - class DisplayLayoutView { constructor(openmct, domainObject, objectPath, options) { this.openmct = openmct; @@ -123,6 +123,7 @@ export default function DisplayLayoutPlugin(options) { return 100; } }); + openmct.objects.addGetInterceptor(displayLayoutStylesInterceptor(openmct)); openmct.types.addType('layout', DisplayLayoutType()); openmct.toolbars.addProvider(new DisplayLayoutToolbar(openmct)); openmct.inspectorViews.addProvider(new AlphaNumericFormatViewProvider(openmct, options)); diff --git a/src/plugins/flexibleLayout/components/FlexibleLayout.vue b/src/plugins/flexibleLayout/components/FlexibleLayout.vue index 7ec37341f0..6019e5390a 100644 --- a/src/plugins/flexibleLayout/components/FlexibleLayout.vue +++ b/src/plugins/flexibleLayout/components/FlexibleLayout.vue @@ -159,11 +159,6 @@ export default { this.composition.on('add', this.addFrame); this.composition.load(); - // Initialize objectStyles if it doesn't exist for older versions - if (!this.domainObject.configuration.objectStyles) { - this.domainObject.configuration.objectStyles = {}; - } - this.unObserveContainers = this.openmct.objects.observe( this.domainObject, 'configuration.containers', diff --git a/src/plugins/flexibleLayout/flexibleLayoutStylesInterceptor.js b/src/plugins/flexibleLayout/flexibleLayoutStylesInterceptor.js new file mode 100644 index 0000000000..78cfdb3121 --- /dev/null +++ b/src/plugins/flexibleLayout/flexibleLayoutStylesInterceptor.js @@ -0,0 +1,40 @@ +/***************************************************************************** + * 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 displayLayoutStylesInterceptor(openmct) { + return { + appliesTo: (identifier, domainObject) => { + return domainObject?.type === 'flexible-layout'; + }, + invoke: (identifier, domainObject) => { + if (!domainObject.configuration) { + domainObject.configuration = {}; + } + + if (!domainObject.configuration.objectStyles) { + domainObject.configuration.objectStyles = {}; + } + + return domainObject; + } + }; +} diff --git a/src/plugins/flexibleLayout/plugin.js b/src/plugins/flexibleLayout/plugin.js index f05aefaf90..e7ae578ddc 100644 --- a/src/plugins/flexibleLayout/plugin.js +++ b/src/plugins/flexibleLayout/plugin.js @@ -20,6 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ +import flexibleLayoutStylesInterceptor from './flexibleLayoutStylesInterceptor.js'; import FlexibleLayoutViewProvider from './flexibleLayoutViewProvider.js'; import ToolBarProvider from './toolbarProvider.js'; import Container from './utils/container.js'; @@ -43,6 +44,7 @@ export default function plugin() { domainObject.composition = []; } }); + openmct.objects.addGetInterceptor(flexibleLayoutStylesInterceptor(openmct)); let toolbar = ToolBarProvider(openmct); diff --git a/src/plugins/gauge/GaugePlugin.js b/src/plugins/gauge/GaugePlugin.js index 3b2ebeeef2..56d4ca33ad 100644 --- a/src/plugins/gauge/GaugePlugin.js +++ b/src/plugins/gauge/GaugePlugin.js @@ -24,6 +24,7 @@ import mount from 'utils/mount'; import GaugeFormController from './components/GaugeFormController.vue'; import GaugeCompositionPolicy from './GaugeCompositionPolicy.js'; +import gaugeStylesInterceptor from './gaugeStylesInterceptor.js'; import GaugeViewProvider from './GaugeViewProvider.js'; export const GAUGE_TYPES = [ @@ -37,7 +38,7 @@ export const GAUGE_TYPES = [ export default function () { return function install(openmct) { openmct.objectViews.addProvider(new GaugeViewProvider(openmct)); - + openmct.objects.addGetInterceptor(gaugeStylesInterceptor(openmct)); openmct.forms.addNewFormControl('gauge-controller', getGaugeFormController(openmct)); openmct.types.addType('gauge', { name: 'Gauge', diff --git a/src/plugins/gauge/components/GaugeComponent.vue b/src/plugins/gauge/components/GaugeComponent.vue index f075e6ef8c..080d6593c1 100644 --- a/src/plugins/gauge/components/GaugeComponent.vue +++ b/src/plugins/gauge/components/GaugeComponent.vue @@ -553,11 +553,6 @@ export default { this.openmct.time.on('boundsChanged', this.refreshData); this.openmct.time.on('timeSystem', this.setTimeSystem); - // Initialize objectStyles if it doesn't exist - if (!this.domainObject.configuration.objectStyles) { - this.domainObject.configuration.objectStyles = {}; - } - this.setupClockChangedEvent((domainObject) => { this.triggerUnsubscribeFromStaleness(domainObject); this.subscribeToStaleness(domainObject); diff --git a/src/plugins/gauge/gaugeStylesInterceptor.js b/src/plugins/gauge/gaugeStylesInterceptor.js new file mode 100644 index 0000000000..5febb34873 --- /dev/null +++ b/src/plugins/gauge/gaugeStylesInterceptor.js @@ -0,0 +1,40 @@ +/***************************************************************************** + * 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 gaugeStylesInterceptor(openmct) { + return { + appliesTo: (identifier, domainObject) => { + return domainObject?.type === 'gauge'; + }, + invoke: (identifier, domainObject) => { + if (!domainObject.configuration) { + domainObject.configuration = {}; + } + + if (!domainObject.configuration.objectStyles) { + domainObject.configuration.objectStyles = {}; + } + + return domainObject; + } + }; +} diff --git a/src/plugins/inspectorViews/elements/ElementsPool.vue b/src/plugins/inspectorViews/elements/ElementsPool.vue index a7c3dd7907..d17098f0f8 100644 --- a/src/plugins/inspectorViews/elements/ElementsPool.vue +++ b/src/plugins/inspectorViews/elements/ElementsPool.vue @@ -93,7 +93,6 @@ export default { methods: { setEditState(isEditing) { this.isEditing = isEditing; - console.log('this.isEditing', this.isEditing); this.showSelection(this.openmct.selection.get()); }, showSelection(selection) {