mirror of
https://github.com/nasa/openmct.git
synced 2025-05-08 11:38:35 +00:00
Tables composition error (#2260)
* Removed debubgging statement * Change order of mutation events so that composition handlers are working with latest object version. * Remove suppression of mutation event * Minor code reformatting
This commit is contained in:
parent
00ce246fc5
commit
6b1e8862ef
@ -58,11 +58,8 @@ define([
|
|||||||
|
|
||||||
handleLegacyMutation = function (legacyObject) {
|
handleLegacyMutation = function (legacyObject) {
|
||||||
var newStyleObject = utils.toNewFormat(legacyObject.getModel(), legacyObject.getId());
|
var newStyleObject = utils.toNewFormat(legacyObject.getModel(), legacyObject.getId());
|
||||||
|
|
||||||
//Don't trigger self
|
|
||||||
this.eventEmitter.off('mutation', handleMutation);
|
|
||||||
this.eventEmitter.emit(newStyleObject.identifier.key + ":*", newStyleObject);
|
this.eventEmitter.emit(newStyleObject.identifier.key + ":*", newStyleObject);
|
||||||
this.eventEmitter.on('mutation', handleMutation);
|
this.eventEmitter.emit('mutation', newStyleObject);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.eventEmitter.on('mutation', handleMutation);
|
this.eventEmitter.on('mutation', handleMutation);
|
||||||
|
@ -46,6 +46,7 @@ define([
|
|||||||
function DefaultCompositionProvider(publicAPI, compositionAPI) {
|
function DefaultCompositionProvider(publicAPI, compositionAPI) {
|
||||||
this.publicAPI = publicAPI;
|
this.publicAPI = publicAPI;
|
||||||
this.listeningTo = {};
|
this.listeningTo = {};
|
||||||
|
this.onMutation = this.onMutation.bind(this);
|
||||||
|
|
||||||
this.cannotContainDuplicates = this.cannotContainDuplicates.bind(this);
|
this.cannotContainDuplicates = this.cannotContainDuplicates.bind(this);
|
||||||
this.cannotContainItself = this.cannotContainItself.bind(this);
|
this.cannotContainItself = this.cannotContainItself.bind(this);
|
||||||
@ -208,9 +209,10 @@ define([
|
|||||||
if (this.topicListener) {
|
if (this.topicListener) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var topic = this.publicAPI.$injector.get('topic');
|
this.publicAPI.objects.eventEmitter.on('mutation', this.onMutation);
|
||||||
var mutation = topic('mutation');
|
this.topicListener = () => {
|
||||||
this.topicListener = mutation.listen(this.onMutation.bind(this));
|
this.publicAPI.objects.eventEmitter.off('mutation', this.onMutation)
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,7 +222,7 @@ define([
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.onMutation = function (oldDomainObject) {
|
DefaultCompositionProvider.prototype.onMutation = function (oldDomainObject) {
|
||||||
var id = oldDomainObject.getId();
|
var id = objectUtils.makeKeyString(oldDomainObject.identifier);
|
||||||
var listeners = this.listeningTo[id];
|
var listeners = this.listeningTo[id];
|
||||||
|
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
@ -228,7 +230,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
var oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
var oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
||||||
var newComposition = oldDomainObject.getModel().composition.map(objectUtils.makeKeyString);
|
var newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString);
|
||||||
|
|
||||||
var added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
var added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
||||||
var removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
var removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
||||||
|
@ -83,18 +83,15 @@ define([
|
|||||||
this.object = newObject;
|
this.object = newObject;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.eventEmitter.on(qualifiedEventName(this.object, '*'), handleRecursiveMutation);
|
//Emit wildcard event
|
||||||
|
|
||||||
//Emit event specific to property
|
|
||||||
this.eventEmitter.emit(qualifiedEventName(this.object, path), value);
|
|
||||||
|
|
||||||
this.eventEmitter.off(qualifiedEventName(this.object, '*'), handleRecursiveMutation);
|
|
||||||
|
|
||||||
//Emit wildcare event
|
|
||||||
this.eventEmitter.emit(qualifiedEventName(this.object, '*'), this.object);
|
this.eventEmitter.emit(qualifiedEventName(this.object, '*'), this.object);
|
||||||
|
|
||||||
//Emit a general "any object" event
|
//Emit a general "any object" event
|
||||||
this.eventEmitter.emit(ANY_OBJECT_EVENT, this.object);
|
this.eventEmitter.emit(ANY_OBJECT_EVENT, this.object);
|
||||||
|
|
||||||
|
this.eventEmitter.on(qualifiedEventName(this.object, '*'), handleRecursiveMutation);
|
||||||
|
//Emit event specific to property
|
||||||
|
this.eventEmitter.emit(qualifiedEventName(this.object, path), value);
|
||||||
|
this.eventEmitter.off(qualifiedEventName(this.object, '*'), handleRecursiveMutation);
|
||||||
};
|
};
|
||||||
|
|
||||||
return MutableObject;
|
return MutableObject;
|
||||||
|
@ -79,8 +79,8 @@ define([
|
|||||||
|
|
||||||
loadComposition() {
|
loadComposition() {
|
||||||
this.tableComposition = this.openmct.composition.get(this.domainObject);
|
this.tableComposition = this.openmct.composition.get(this.domainObject);
|
||||||
if (this.tableComposition !== undefined){
|
if (this.tableComposition !== undefined) {
|
||||||
this.tableComposition.load().then((composition)=>{
|
this.tableComposition.load().then((composition) => {
|
||||||
composition = composition.filter(this.isTelemetryObject);
|
composition = composition.filter(this.isTelemetryObject);
|
||||||
|
|
||||||
this.configuration.addColumnsForAllObjects(composition);
|
this.configuration.addColumnsForAllObjects(composition);
|
||||||
@ -122,7 +122,6 @@ define([
|
|||||||
|
|
||||||
let telemetryRows = telemetryData.map(datum => new TelemetryTableRow(datum, columnMap, keyString, limitEvaluator));
|
let telemetryRows = telemetryData.map(datum => new TelemetryTableRow(datum, columnMap, keyString, limitEvaluator));
|
||||||
this.boundedRows.add(telemetryRows);
|
this.boundedRows.add(telemetryRows);
|
||||||
console.log('Loaded %i rows', telemetryRows.length);
|
|
||||||
this.decrementOutstandingRequests();
|
this.decrementOutstandingRequests();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,7 +130,7 @@ define([
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
incrementOutstandingRequests() {
|
incrementOutstandingRequests() {
|
||||||
if (this.outstandingRequests === 0){
|
if (this.outstandingRequests === 0) {
|
||||||
this.emit('outstanding-requests', true);
|
this.emit('outstanding-requests', true);
|
||||||
}
|
}
|
||||||
this.outstandingRequests++;
|
this.outstandingRequests++;
|
||||||
@ -143,7 +142,7 @@ define([
|
|||||||
decrementOutstandingRequests() {
|
decrementOutstandingRequests() {
|
||||||
this.outstandingRequests--;
|
this.outstandingRequests--;
|
||||||
|
|
||||||
if (this.outstandingRequests === 0){
|
if (this.outstandingRequests === 0) {
|
||||||
this.emit('outstanding-requests', false);
|
this.emit('outstanding-requests', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ define([
|
|||||||
objectMutated(object) {
|
objectMutated(object) {
|
||||||
//Synchronize domain object reference. Duplicate object otherwise change detection becomes impossible.
|
//Synchronize domain object reference. Duplicate object otherwise change detection becomes impossible.
|
||||||
this.domainObject = object;
|
this.domainObject = object;
|
||||||
|
//Was it the configuration that changed?
|
||||||
if (!_.eq(object.configuration, this.oldConfiguration)) {
|
if (!_.eq(object.configuration, this.oldConfiguration)) {
|
||||||
//Make copy of configuration, otherwise change detection is impossible if shared instance is being modified.
|
//Make copy of configuration, otherwise change detection is impossible if shared instance is being modified.
|
||||||
this.oldConfiguration = JSON.parse(JSON.stringify(this.getConfiguration()));
|
this.oldConfiguration = JSON.parse(JSON.stringify(this.getConfiguration()));
|
||||||
@ -91,16 +92,19 @@ define([
|
|||||||
let columnsToRemove = this.columns[objectKeyString];
|
let columnsToRemove = this.columns[objectKeyString];
|
||||||
|
|
||||||
delete this.columns[objectKeyString];
|
delete this.columns[objectKeyString];
|
||||||
|
|
||||||
|
let configuration = this.domainObject.configuration;
|
||||||
|
let configurationChanged = false;
|
||||||
columnsToRemove.forEach((column) => {
|
columnsToRemove.forEach((column) => {
|
||||||
//There may be more than one column with the same key (eg. time system columns)
|
//There may be more than one column with the same key (eg. time system columns)
|
||||||
if (!this.hasColumnWithKey(column.getKey())) {
|
if (!this.hasColumnWithKey(column.getKey())) {
|
||||||
let configuration = this.domainObject.configuration;
|
|
||||||
delete configuration.hiddenColumns[column.getKey()];
|
delete configuration.hiddenColumns[column.getKey()];
|
||||||
// If there are no more columns with this key, delete any configuration, and trigger
|
configurationChanged = true;
|
||||||
// a column refresh.
|
|
||||||
this.openmct.objects.mutate(this.domainObject, 'configuration', configuration);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (configurationChanged) {
|
||||||
|
this.updateConfiguration(configuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasColumnWithKey(columnKey) {
|
hasColumnWithKey(columnKey) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user