diff --git a/src/plugins/telemetryTable/TelemetryTableConfiguration.js b/src/plugins/telemetryTable/TelemetryTableConfiguration.js index 2703aa7019..1a94c96d23 100644 --- a/src/plugins/telemetryTable/TelemetryTableConfiguration.js +++ b/src/plugins/telemetryTable/TelemetryTableConfiguration.js @@ -36,11 +36,6 @@ export default class TelemetryTableConfiguration extends EventEmitter { this.defaultOptions = options; this.columns = {}; - // Initialize objectStyles if it doesn't exist, for items with configuration - if (this.domainObject.configuration && !this.domainObject.configuration.objectStyles) { - this.domainObject.configuration.objectStyles = {}; - } - this.removeColumnsForObject = this.removeColumnsForObject.bind(this); this.objectMutated = this.objectMutated.bind(this); diff --git a/src/plugins/telemetryTable/plugin.js b/src/plugins/telemetryTable/plugin.js index ba12c20fd3..d5506bb6a4 100644 --- a/src/plugins/telemetryTable/plugin.js +++ b/src/plugins/telemetryTable/plugin.js @@ -22,6 +22,7 @@ import { MODE } from './constants.js'; import TableConfigurationViewProvider from './TableConfigurationViewProvider.js'; +import telemetryTableStylesInterceptor from './telemetryTableStylesInterceptor.js'; import getTelemetryTableType from './TelemetryTableType.js'; import TelemetryTableViewProvider from './TelemetryTableViewProvider.js'; import TelemetryTableViewActions from './ViewActions.js'; @@ -33,6 +34,7 @@ export default function plugin( openmct.objectViews.addProvider(new TelemetryTableViewProvider(openmct, options)); openmct.inspectorViews.addProvider(new TableConfigurationViewProvider(openmct, options)); openmct.types.addType('table', getTelemetryTableType(options)); + openmct.objects.addGetInterceptor(telemetryTableStylesInterceptor(openmct)); openmct.composition.addPolicy((parent, child) => { if (parent.type === 'table') { return Object.prototype.hasOwnProperty.call(child, 'telemetry'); diff --git a/src/plugins/telemetryTable/telemetryTableStylesInterceptor.js b/src/plugins/telemetryTable/telemetryTableStylesInterceptor.js new file mode 100644 index 0000000000..b0524c061b --- /dev/null +++ b/src/plugins/telemetryTable/telemetryTableStylesInterceptor.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 telemetryTableStylesInterceptor(openmct) { + return { + appliesTo: (identifier, domainObject) => { + return ( + domainObject.type === 'table' && + domainObject.configuration && // only applies to tables with existing configuration + !domainObject.configuration.objectStyles + ); + }, + invoke: (identifier, domainObject) => { + domainObject.configuration.objectStyles = {}; + + openmct.objects.save(domainObject); + + return domainObject; + } + }; +}