3175 - Enable listening to clearData action for Imagery (#4733)
* Add clearData listener for imageryData module * Remove commented out code * Updated imagery clear data test * Adjusted telemetry stub to return empty array if data cleared * Remove forced test * Restub telemetry before * Cleanup and reset clear data boolean after * Remove double blank line Co-authored-by: Scott Bell <scott@traclabs.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@ export default {
|
||||
this.timeSystemChange = this.timeSystemChange.bind(this);
|
||||
this.setDataTimeContext = this.setDataTimeContext.bind(this);
|
||||
this.setDataTimeContext();
|
||||
this.openmct.objectViews.on('clearData', this.clearData);
|
||||
|
||||
// set
|
||||
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
@@ -54,6 +55,7 @@ export default {
|
||||
}
|
||||
|
||||
this.stopFollowingDataTimeContext();
|
||||
this.openmct.objectViews.off('clearData', this.clearData);
|
||||
},
|
||||
methods: {
|
||||
setDataTimeContext() {
|
||||
@@ -151,6 +153,25 @@ export default {
|
||||
this.imageHistory = imagery;
|
||||
}
|
||||
},
|
||||
clearData(domainObjectToClear) {
|
||||
// global clearData button is accepted therefore no truthy check on inputted param
|
||||
const clearDataForObjectSelected = Boolean(domainObjectToClear);
|
||||
if (clearDataForObjectSelected) {
|
||||
const idsEqual = this.openmct.objects.areIdsEqual(
|
||||
domainObjectToClear.identifier,
|
||||
this.domainObject.identifier
|
||||
);
|
||||
if (!idsEqual) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// splice array to encourage garbage collection
|
||||
this.imageHistory.splice(0, this.imageHistory.length);
|
||||
|
||||
// requesting history effectively clears imageHistory array
|
||||
return this.requestHistory();
|
||||
},
|
||||
timeSystemChange() {
|
||||
this.timeSystem = this.timeContext.timeSystem();
|
||||
this.timeKey = this.timeSystem.key;
|
||||
|
||||
Reference in New Issue
Block a user