diff --git a/src/api/objects/MutableDomainObject.js b/src/api/objects/MutableDomainObject.js index 2ac35f7b38..b1dc83fc60 100644 --- a/src/api/objects/MutableDomainObject.js +++ b/src/api/objects/MutableDomainObject.js @@ -112,9 +112,11 @@ class MutableDomainObject { return () => this._instanceEventEmitter.off(event, callback); } $destroy() { - this._observers.forEach(observer => observer()); - delete this._globalEventEmitter; - delete this._observers; + while (this._observers.length > 0) { + const observer = this._observers.pop(); + observer(); + } + this._instanceEventEmitter.emit('$_destroy'); } diff --git a/src/plugins/filters/components/FiltersView.vue b/src/plugins/filters/components/FiltersView.vue index 0bcb1a8391..0c99dce13a 100644 --- a/src/plugins/filters/components/FiltersView.vue +++ b/src/plugins/filters/components/FiltersView.vue @@ -90,14 +90,12 @@ export default { this.composition.load(); this.unobserve = this.openmct.objects.observe(this.providedObject, 'configuration.filters', this.updatePersistedFilters); this.unobserveGlobalFilters = this.openmct.objects.observe(this.providedObject, 'configuration.globalFilters', this.updateGlobalFilters); - this.unobserveAllMutation = this.openmct.objects.observe(this.providedObject, '*', (mutatedObject) => this.providedObject = mutatedObject); }, beforeDestroy() { this.composition.off('add', this.addChildren); this.composition.off('remove', this.removeChildren); this.unobserve(); this.unobserveGlobalFilters(); - this.unobserveAllMutation(); }, methods: { addChildren(domainObject) { @@ -158,25 +156,28 @@ export default { }, getGlobalFiltersToRemove(keyString) { let filtersToRemove = new Set(); + const child = this.children[keyString]; + if (child && child.metadataWithFilters) { + const metadataWithFilters = child.metadataWithFilters; + metadataWithFilters.forEach(metadatum => { + let keepFilter = false; + Object.keys(this.children).forEach(childKeyString => { + if (childKeyString !== keyString) { + let filterMatched = this.children[childKeyString].metadataWithFilters.some(childMetadatum => childMetadatum.key === metadatum.key); - this.children[keyString].metadataWithFilters.forEach(metadatum => { - let keepFilter = false; - Object.keys(this.children).forEach(childKeyString => { - if (childKeyString !== keyString) { - let filterMatched = this.children[childKeyString].metadataWithFilters.some(childMetadatum => childMetadatum.key === metadatum.key); + if (filterMatched) { + keepFilter = true; - if (filterMatched) { - keepFilter = true; - - return; + return; + } } + }); + + if (!keepFilter) { + filtersToRemove.add(metadatum.key); } }); - - if (!keepFilter) { - filtersToRemove.add(metadatum.key); - } - }); + } return Array.from(filtersToRemove); }, diff --git a/src/plugins/plot/src/configuration/PlotSeries.js b/src/plugins/plot/src/configuration/PlotSeries.js index 73740c5b71..77112600e5 100644 --- a/src/plugins/plot/src/configuration/PlotSeries.js +++ b/src/plugins/plot/src/configuration/PlotSeries.js @@ -413,6 +413,10 @@ define([ * @public */ updateFiltersAndRefresh: function (updatedFilters) { + if (updatedFilters === undefined) { + return; + } + let deepCopiedFilters = JSON.parse(JSON.stringify(updatedFilters)); if (this.filters && !_.isEqual(this.filters, deepCopiedFilters)) { diff --git a/src/plugins/plot/vue/single/configuration/PlotSeries.js b/src/plugins/plot/vue/single/configuration/PlotSeries.js index 2f7988d59f..0d594ec939 100644 --- a/src/plugins/plot/vue/single/configuration/PlotSeries.js +++ b/src/plugins/plot/vue/single/configuration/PlotSeries.js @@ -403,6 +403,10 @@ export default class PlotSeries extends Model { * @public */ updateFiltersAndRefresh(updatedFilters) { + if (updatedFilters === undefined) { + return; + } + let deepCopiedFilters = JSON.parse(JSON.stringify(updatedFilters)); if (this.filters && !_.isEqual(this.filters, deepCopiedFilters)) { diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index af9613ee1c..e1a7a00ed8 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -222,11 +222,15 @@ define([ getColumnMapForObject(objectKeyString) { let columns = this.configuration.getColumns(); - return columns[objectKeyString].reduce((map, column) => { - map[column.getKey()] = column; + if (columns[objectKeyString]) { + return columns[objectKeyString].reduce((map, column) => { + map[column.getKey()] = column; - return map; - }, {}); + return map; + }, {}); + } + + return {}; } addColumnsForObject(telemetryObject) { diff --git a/src/plugins/telemetryTable/TelemetryTableConfiguration.js b/src/plugins/telemetryTable/TelemetryTableConfiguration.js index 3ff9816351..3ba170303b 100644 --- a/src/plugins/telemetryTable/TelemetryTableConfiguration.js +++ b/src/plugins/telemetryTable/TelemetryTableConfiguration.js @@ -37,8 +37,6 @@ define([ this.objectMutated = this.objectMutated.bind(this); //Make copy of configuration, otherwise change detection is impossible if shared instance is being modified. this.oldConfiguration = JSON.parse(JSON.stringify(this.getConfiguration())); - - this.unlistenFromMutation = openmct.objects.observe(domainObject, '*', this.objectMutated); } getConfiguration() { @@ -164,9 +162,7 @@ define([ this.updateConfiguration(configuration); } - destroy() { - this.unlistenFromMutation(); - } + destroy() {} } return TelemetryTableConfiguration; diff --git a/src/selection/Selection.js b/src/selection/Selection.js index ad2849758d..af1db59a41 100644 --- a/src/selection/Selection.js +++ b/src/selection/Selection.js @@ -237,11 +237,13 @@ define( const capture = this.capture.bind(this, selectable); const selectCapture = this.selectCapture.bind(this, selectable); + let removeMutable = false; element.addEventListener('click', capture, true); element.addEventListener('click', selectCapture); - if (context.item) { + if (context.item && context.item.isMutable !== true) { + removeMutable = true; context.item = this.openmct.objects._toMutable(context.item); } @@ -257,7 +259,7 @@ define( element.removeEventListener('click', capture, true); element.removeEventListener('click', selectCapture); - if (context.item !== undefined && context.item.isMutable) { + if (context.item !== undefined && context.item.isMutable && removeMutable === true) { this.openmct.objects.destroyMutable(context.item); } }).bind(this);