mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
fix(overlay plot): legend updates correctly when removing element via remove action (#7531)
* fix: remove duplicate listeners * fix: if no series found, don't splice * test(e2e): update legend a11y and add test
This commit is contained in:
parent
0bdd0963a4
commit
39ab81c3d0
@ -356,6 +356,10 @@ test.describe('Overlay Plot', () => {
|
|||||||
type: 'Sine Wave Generator',
|
type: 'Sine Wave Generator',
|
||||||
parent: overlayPlot.uuid
|
parent: overlayPlot.uuid
|
||||||
});
|
});
|
||||||
|
const swgB = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
parent: overlayPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
await page.goto(overlayPlot.url);
|
await page.goto(overlayPlot.url);
|
||||||
// Wait for plot series data to load and be drawn
|
// Wait for plot series data to load and be drawn
|
||||||
@ -370,6 +374,23 @@ test.describe('Overlay Plot', () => {
|
|||||||
await page.getByRole('menuitem', { name: 'Remove' }).click();
|
await page.getByRole('menuitem', { name: 'Remove' }).click();
|
||||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||||
await expect(swgAElementsPoolItem).toBeHidden();
|
await expect(swgAElementsPoolItem).toBeHidden();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7530'
|
||||||
|
});
|
||||||
|
await test.step('Verify that the legend is correct after removing a series', async () => {
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
await page.mouse.move(50, 0, {
|
||||||
|
steps: 10
|
||||||
|
});
|
||||||
|
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(1);
|
||||||
|
await expect(page.getByLabel(`Plot Legend Item for ${swgA.name}`)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(`Plot Legend Item for ${swgB.name}`)).toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -165,7 +165,6 @@ export default {
|
|||||||
this.registerListeners(this.config);
|
this.registerListeners(this.config);
|
||||||
}
|
}
|
||||||
this.listenTo(this.config.legend, 'change:expandByDefault', this.changeExpandDefault, this);
|
this.listenTo(this.config.legend, 'change:expandByDefault', this.changeExpandDefault, this);
|
||||||
this.initialize();
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
@ -182,16 +181,6 @@ export default {
|
|||||||
this.stopListening();
|
this.stopListening();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initialize() {
|
|
||||||
if (this.domainObject.type === 'telemetry.plot.stacked') {
|
|
||||||
this.objectComposition = this.openmct.composition.get(this.domainObject);
|
|
||||||
this.objectComposition.on('add', this.addTelemetryObject);
|
|
||||||
this.objectComposition.on('remove', this.removeTelemetryObject);
|
|
||||||
this.objectComposition.load();
|
|
||||||
} else {
|
|
||||||
this.registerListeners(this.config);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
changeExpandDefault() {
|
changeExpandDefault() {
|
||||||
this.isLegendExpanded = this.config.legend.model.expandByDefault;
|
this.isLegendExpanded = this.config.legend.model.expandByDefault;
|
||||||
this.legend.set('expanded', this.isLegendExpanded);
|
this.legend.set('expanded', this.isLegendExpanded);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="plot-legend-item"
|
class="plot-legend-item"
|
||||||
:aria-label="`Plot Legend Item for ${domainObject?.name}`"
|
:aria-label="`Plot Legend Item for ${seriesName}`"
|
||||||
:class="{
|
:class="{
|
||||||
'is-stale': isStale,
|
'is-stale': isStale,
|
||||||
'is-status--missing': isMissing
|
'is-status--missing': isMissing
|
||||||
@ -36,9 +36,8 @@
|
|||||||
@mouseover.ctrl="showToolTip"
|
@mouseover.ctrl="showToolTip"
|
||||||
@mouseleave="hideToolTip"
|
@mouseleave="hideToolTip"
|
||||||
>
|
>
|
||||||
<span class="plot-series-color-swatch" :style="{ 'background-color': colorAsHexString }">
|
<span class="plot-series-color-swatch" :style="{ 'background-color': colorAsHexString }" />
|
||||||
</span>
|
<span class="is-status__indicator" title="This item is missing or suspect" />
|
||||||
<span class="is-status__indicator" title="This item is missing or suspect"></span>
|
|
||||||
<span class="plot-series-name">{{ nameWithUnit }}</span>
|
<span class="plot-series-name">{{ nameWithUnit }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -89,6 +88,7 @@ export default {
|
|||||||
isMissing: false,
|
isMissing: false,
|
||||||
colorAsHexString: '',
|
colorAsHexString: '',
|
||||||
nameWithUnit: '',
|
nameWithUnit: '',
|
||||||
|
seriesName: '',
|
||||||
formattedYValue: '',
|
formattedYValue: '',
|
||||||
formattedXValue: '',
|
formattedXValue: '',
|
||||||
mctLimitStateClass: '',
|
mctLimitStateClass: '',
|
||||||
@ -206,6 +206,9 @@ export default {
|
|||||||
const seriesIndexToRemove = this.seriesModels.findIndex(
|
const seriesIndexToRemove = this.seriesModels.findIndex(
|
||||||
(series) => series.keyString === seriesToRemove.keyString
|
(series) => series.keyString === seriesToRemove.keyString
|
||||||
);
|
);
|
||||||
|
if (seriesIndexToRemove === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.seriesModels.splice(seriesIndexToRemove, 1);
|
this.seriesModels.splice(seriesIndexToRemove, 1);
|
||||||
},
|
},
|
||||||
getSeries(keyStringToFind) {
|
getSeries(keyStringToFind) {
|
||||||
@ -220,6 +223,7 @@ export default {
|
|||||||
|
|
||||||
this.isMissing = seriesObject.domainObject.status === 'missing';
|
this.isMissing = seriesObject.domainObject.status === 'missing';
|
||||||
this.colorAsHexString = seriesObject.get('color').asHexString();
|
this.colorAsHexString = seriesObject.get('color').asHexString();
|
||||||
|
this.seriesName = seriesObject.domainObject.name;
|
||||||
this.nameWithUnit = seriesObject.nameWithUnit();
|
this.nameWithUnit = seriesObject.nameWithUnit();
|
||||||
|
|
||||||
const closest = seriesObject.closest;
|
const closest = seriesObject.closest;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user