Skip to content

Commit

Permalink
Timelist views support fixed time - 5629 (#5726)
Browse files Browse the repository at this point in the history
* Initialize full view for fixed time

* Clean up

* Add back in ticker after merge

* Check for undefined clock instead of timestamp

* Cleanup

* Initialize full view for fixed time

* Clean up

* Add back in ticker after merge

* Check for undefined clock instead of timestamp

* Cleanup

* Update timestamp method and remove from beforeDestroy

* Shorten ternary to optional chaining

* Cleanup unused var

* Moved duplicated logic to method

* Reorder methods

* Update Timelist.vue

Set timestamp to clock start when in fixed time

* Added blank line

* Lint fix

* Update pluginSpec.js

* Invoke currentValue method properly
  • Loading branch information
michaelrogers committed Sep 15, 2022
1 parent be4450d commit b85f0db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/plugins/timelist/Timelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ export default {
},
mounted() {
this.isEditing = this.openmct.editor.isEditing();
this.timestamp = Date.now();
this.timestamp = this.openmct.time.clock()?.currentValue() || this.openmct.time.bounds()?.start;
this.openmct.time.on('clock', this.setViewFromClock);
this.getPlanDataAndSetConfig(this.domainObject);
this.unlisten = this.openmct.objects.observe(this.domainObject, 'selectFile', this.planFileUpdated);
this.unlistenConfig = this.openmct.objects.observe(this.domainObject, 'configuration', this.setViewFromConfig);
this.removeStatusListener = this.openmct.status.observe(this.domainObject.identifier, this.setStatus);
this.status = this.openmct.status.get(this.domainObject.identifier);
this.unlistenTicker = ticker.listen(this.clearPreviousActivities);
this.openmct.time.on('bounds', this.updateTimestamp);
this.openmct.editor.on('isEditing', this.setEditState);
this.deferAutoScroll = _.debounce(this.deferAutoScroll, 500);
Expand All @@ -128,6 +131,9 @@ export default {
this.composition.on('remove', this.removeItem);
this.composition.load();
}
this.setViewFromClock(this.openmct.time.clock());
},
beforeDestroy() {
if (this.unlisten) {
Expand All @@ -147,6 +153,8 @@ export default {
}
this.openmct.editor.off('isEditing', this.setEditState);
this.openmct.time.off('bounds', this.updateTimestamp);
this.openmct.time.off('clock', this.setViewFromClock);
this.$el.parentElement.removeEventListener('scroll', this.deferAutoScroll, true);
if (this.clearAutoScrollDisabledTimer) {
Expand Down Expand Up @@ -176,12 +184,32 @@ export default {
this.showAll = true;
this.listActivities();
} else {
this.filterValue = configuration.filter;
this.setSort();
this.setViewBounds();
this.listActivities();
}
},
updateTimestamp(_bounds, isTick) {
if (isTick === true) {
this.timestamp = this.openmct.time.clock().currentValue();
}
},
setViewFromClock(newClock) {
this.filterValue = this.domainObject.configuration.filter;
const isFixedTime = newClock === undefined;
if (isFixedTime) {
this.hideAll = false;
this.showAll = true;
// clear invokes listActivities
this.clearPreviousActivities(this.openmct.time.bounds()?.start);
} else {
this.setSort();
this.setViewBounds();
this.listActivities();
}
},
addItem(domainObject) {
this.planObjects = [domainObject];
this.resetPlanData();
Expand Down Expand Up @@ -400,7 +428,7 @@ export default {
this.firstCurrentActivityIndex = -1;
this.currentActivitiesCount = 0;
this.$el.parentElement.scrollTo({top: 0});
this.$el.parentElement?.scrollTo({top: 0});
this.autoScrolled = false;
},
setScrollTop() {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timelist/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe('the plugin', function () {

return Vue.nextTick(() => {
const items = element.querySelectorAll(LIST_ITEM_CLASS);
expect(items.length).toEqual(1);
expect(items.length).toEqual(2);
});
});
});
Expand Down

0 comments on commit b85f0db

Please sign in to comment.