update previous interceptors and add for stacked plot

This commit is contained in:
Jamie V 2025-03-03 14:23:25 -08:00
parent f98cabe13b
commit 8655434e4b
5 changed files with 24 additions and 18 deletions

View File

@ -23,7 +23,7 @@
export default function conditionWidgetStylesInterceptor(openmct) {
return {
appliesTo: (identifier, domainObject) => {
return identifier.key === 'conditionWidget' && !domainObject.configuration?.objectStyles;
return domainObject.type === 'conditionWidget' && !domainObject?.configuration?.objectStyles;
},
invoke: (identifier, domainObject) => {
if (!domainObject.configuration) {
@ -35,7 +35,6 @@ export default function conditionWidgetStylesInterceptor(openmct) {
openmct.objects.save(domainObject);
return domainObject;
},
priority: openmct.priority.DEFAULT
}
};
}

View File

@ -24,7 +24,7 @@ export default function overlayPlotStylesInterceptor(openmct) {
return {
appliesTo: (identifier, domainObject) => {
return (
identifier.key === 'telemetry.plot.overlay' && !domainObject.configuration?.objectStyles
domainObject.type === 'telemetry.plot.overlay' && !domainObject?.configuration?.objectStyles
);
},
invoke: (identifier, domainObject) => {
@ -37,7 +37,6 @@ export default function overlayPlotStylesInterceptor(openmct) {
openmct.objects.save(domainObject);
return domainObject;
},
priority: openmct.priority.DEFAULT
}
};
}

View File

@ -32,8 +32,6 @@ 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',
@ -53,6 +51,8 @@ export default function () {
priority: 891
});
openmct.objects.addGetInterceptor(overlayPlotStylesInterceptor(openmct));
openmct.types.addType('telemetry.plot.stacked', {
key: 'telemetry.plot.stacked',
name: 'Stacked Plot',

View File

@ -147,11 +147,6 @@ export default {
this.config = this.getConfig(configId);
this.showLegendsForChildren = this.config.legend.get('showLegendsForChildren');
// Initialize objectStyles if it doesn't exist
if (!this.domainObject.configuration.objectStyles) {
this.domainObject.configuration.objectStyles = {};
}
this.loaded = true;
this.imageExporter = new ImageExporter(this.openmct);

View File

@ -23,14 +23,27 @@
export default function stackedPlotConfigurationInterceptor(openmct) {
openmct.objects.addGetInterceptor({
appliesTo: (identifier, domainObject) => {
return domainObject && domainObject.type === 'telemetry.plot.stacked';
return (
domainObject.type === 'telemetry.plot.stacked' &&
(!domainObject.configuration?.series || !domainObject.configuration?.objectStyles)
);
},
invoke: (identifier, object) => {
if (object && object.configuration && object.configuration.series === undefined) {
object.configuration.series = [];
invoke: (identifier, domainObject) => {
if (!domainObject.configuration) {
domainObject.configuration = {};
}
return object;
if (!domainObject.configuration.series) {
domainObject.configuration.series = [];
}
if (!domainObject.configuration.objectStyles) {
domainObject.configuration.objectStyles = {};
}
openmct.objects.save(domainObject);
return domainObject;
}
});
}