Skip to content

Commit b85f0db

Browse files
Timelist views support fixed time - 5629 (#5726)
* 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
1 parent be4450d commit b85f0db

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/plugins/timelist/Timelist.vue

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ export default {
110110
},
111111
mounted() {
112112
this.isEditing = this.openmct.editor.isEditing();
113-
this.timestamp = Date.now();
113+
this.timestamp = this.openmct.time.clock()?.currentValue() || this.openmct.time.bounds()?.start;
114+
this.openmct.time.on('clock', this.setViewFromClock);
115+
114116
this.getPlanDataAndSetConfig(this.domainObject);
115117
116118
this.unlisten = this.openmct.objects.observe(this.domainObject, 'selectFile', this.planFileUpdated);
117119
this.unlistenConfig = this.openmct.objects.observe(this.domainObject, 'configuration', this.setViewFromConfig);
118120
this.removeStatusListener = this.openmct.status.observe(this.domainObject.identifier, this.setStatus);
119121
this.status = this.openmct.status.get(this.domainObject.identifier);
120122
this.unlistenTicker = ticker.listen(this.clearPreviousActivities);
123+
this.openmct.time.on('bounds', this.updateTimestamp);
121124
this.openmct.editor.on('isEditing', this.setEditState);
122125
123126
this.deferAutoScroll = _.debounce(this.deferAutoScroll, 500);
@@ -128,6 +131,9 @@ export default {
128131
this.composition.on('remove', this.removeItem);
129132
this.composition.load();
130133
}
134+
135+
this.setViewFromClock(this.openmct.time.clock());
136+
131137
},
132138
beforeDestroy() {
133139
if (this.unlisten) {
@@ -147,6 +153,8 @@ export default {
147153
}
148154
149155
this.openmct.editor.off('isEditing', this.setEditState);
156+
this.openmct.time.off('bounds', this.updateTimestamp);
157+
this.openmct.time.off('clock', this.setViewFromClock);
150158
151159
this.$el.parentElement.removeEventListener('scroll', this.deferAutoScroll, true);
152160
if (this.clearAutoScrollDisabledTimer) {
@@ -176,12 +184,32 @@ export default {
176184
this.showAll = true;
177185
this.listActivities();
178186
} else {
187+
179188
this.filterValue = configuration.filter;
180189
this.setSort();
181190
this.setViewBounds();
182191
this.listActivities();
183192
}
184193
},
194+
updateTimestamp(_bounds, isTick) {
195+
if (isTick === true) {
196+
this.timestamp = this.openmct.time.clock().currentValue();
197+
}
198+
},
199+
setViewFromClock(newClock) {
200+
this.filterValue = this.domainObject.configuration.filter;
201+
const isFixedTime = newClock === undefined;
202+
if (isFixedTime) {
203+
this.hideAll = false;
204+
this.showAll = true;
205+
// clear invokes listActivities
206+
this.clearPreviousActivities(this.openmct.time.bounds()?.start);
207+
} else {
208+
this.setSort();
209+
this.setViewBounds();
210+
this.listActivities();
211+
}
212+
},
185213
addItem(domainObject) {
186214
this.planObjects = [domainObject];
187215
this.resetPlanData();
@@ -400,7 +428,7 @@ export default {
400428
401429
this.firstCurrentActivityIndex = -1;
402430
this.currentActivitiesCount = 0;
403-
this.$el.parentElement.scrollTo({top: 0});
431+
this.$el.parentElement?.scrollTo({top: 0});
404432
this.autoScrolled = false;
405433
},
406434
setScrollTop() {

src/plugins/timelist/pluginSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ describe('the plugin', function () {
376376

377377
return Vue.nextTick(() => {
378378
const items = element.querySelectorAll(LIST_ITEM_CLASS);
379-
expect(items.length).toEqual(1);
379+
expect(items.length).toEqual(2);
380380
});
381381
});
382382
});

0 commit comments

Comments
 (0)