prevent composition from adding a dupe into layout

This commit is contained in:
Deep Tailor
2020-06-26 13:51:03 -07:00
parent 6dd8d448df
commit d9a94db59d

View File

@ -445,15 +445,43 @@ export default {
this.objectViewMap = {}; this.objectViewMap = {};
this.layoutItems.forEach(this.trackItem); this.layoutItems.forEach(this.trackItem);
}, },
isItemAlreadyTracked(child) {
let found = false,
keyString = this.openmct.objects.makeKeyString(child.identifier);
this.layoutItems.forEach(item => {
if (item.identifier) {
let itemKeyString = this.openmct.objects.makeKeyString(item.identifier);
if (itemKeyString === keyString) {
found = true;
return;
}
}
});
if (found) {
return true;
} else if (this.isTelemetry(child)) {
return this.telemetryViewMap[keyString] && this.objectViewMap[keyString];
} else {
return this.objectViewMap[keyString];
}
},
addChild(child) { addChild(child) {
let keyString = this.openmct.objects.makeKeyString(child.identifier); if (this.isItemAlreadyTracked(child)) {
return;
}
let type;
if (this.isTelemetry(child)) { if (this.isTelemetry(child)) {
if (!this.telemetryViewMap[keyString] && !this.objectViewMap[keyString]) { type = 'telemetry-view';
this.addItem('telemetry-view', child); } else {
} type = 'subobject-view';
} else if (!this.objectViewMap[keyString]) {
this.addItem('subobject-view', child);
} }
this.addItem(type, child);
}, },
removeChild(identifier) { removeChild(identifier) {
let keyString = this.openmct.objects.makeKeyString(identifier); let keyString = this.openmct.objects.makeKeyString(identifier);