Compare commits

...

6 Commits

7 changed files with 41 additions and 27 deletions

View File

@@ -113,6 +113,9 @@ class MutableDomainObject {
}
$destroy() {
this._observers.forEach(observer => observer());
//TODO: the following deletes will not work since they're not configurable properties.
// Also, this._globalEventEmitter doesn't seem to change after the above observer listeners are 'removed'
// Also, probably need to pop items off this._observers here or the items will remain on the array.
delete this._globalEventEmitter;
delete this._observers;
this._instanceEventEmitter.emit('$_destroy');

View File

@@ -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);
},

View File

@@ -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)) {

View File

@@ -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)) {

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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);