mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
[Time Conductor] Fixed issue with zoom slider appearing for time systems that do not support it. Fixes #1349
This commit is contained in:
parent
45de84c183
commit
0785129b7f
@ -204,22 +204,6 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Does the currently selected time system support zooming? To
|
|
||||||
* support zooming a time system must, at a minimum, define some
|
|
||||||
* values for maximum and minimum zoom levels. Additionally
|
|
||||||
* TimeFormats, a related concept, may also support providing time
|
|
||||||
* unit feedback for the zoom level label, eg "seconds, minutes,
|
|
||||||
* hours, etc..."
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
TimeConductorController.prototype.supportsZoom = function () {
|
|
||||||
var timeSystem = this.conductor.timeSystem();
|
|
||||||
return timeSystem &&
|
|
||||||
timeSystem.defaults() &&
|
|
||||||
timeSystem.defaults().zoom;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the bounds change in the time conductor. Synchronizes
|
* Called when the bounds change in the time conductor. Synchronizes
|
||||||
* the bounds values in the time conductor with those in the form
|
* the bounds values in the time conductor with those in the form
|
||||||
@ -230,7 +214,7 @@ define(
|
|||||||
this.$scope.boundsModel.start = bounds.start;
|
this.$scope.boundsModel.start = bounds.start;
|
||||||
this.$scope.boundsModel.end = bounds.end;
|
this.$scope.boundsModel.end = bounds.end;
|
||||||
|
|
||||||
if (this.supportsZoom()) {
|
if (this.supportsZoom) {
|
||||||
this.currentZoom = this.toSliderValue(bounds.end - bounds.start);
|
this.currentZoom = this.toSliderValue(bounds.end - bounds.start);
|
||||||
this.toTimeUnits(bounds.end - bounds.start);
|
this.toTimeUnits(bounds.end - bounds.start);
|
||||||
}
|
}
|
||||||
@ -279,7 +263,7 @@ define(
|
|||||||
timeSystemModel.format = timeSystem.formats()[0];
|
timeSystemModel.format = timeSystem.formats()[0];
|
||||||
timeSystemModel.deltaFormat = timeSystem.deltaFormat();
|
timeSystemModel.deltaFormat = timeSystem.deltaFormat();
|
||||||
|
|
||||||
if (this.supportsZoom()) {
|
if (this.supportsZoom) {
|
||||||
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
|
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
|
||||||
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
|
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
|
||||||
}
|
}
|
||||||
@ -363,7 +347,10 @@ define(
|
|||||||
var selected = this.timeSystems.filter(function (timeSystem) {
|
var selected = this.timeSystems.filter(function (timeSystem) {
|
||||||
return timeSystem.metadata.key === key;
|
return timeSystem.metadata.key === key;
|
||||||
})[0];
|
})[0];
|
||||||
this.conductor.timeSystem(selected, selected.defaults().bounds);
|
if (selected) {
|
||||||
|
this.supportsZoom = !!(selected.defaults() && selected.defaults().zoom);
|
||||||
|
this.conductor.timeSystem(selected, selected.defaults().bounds);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -379,6 +366,7 @@ define(
|
|||||||
this.setParam(SEARCH.TIME_SYSTEM, newTimeSystem.metadata.key);
|
this.setParam(SEARCH.TIME_SYSTEM, newTimeSystem.metadata.key);
|
||||||
|
|
||||||
if (newTimeSystem && (newTimeSystem !== this.$scope.timeSystemModel.selected)) {
|
if (newTimeSystem && (newTimeSystem !== this.$scope.timeSystemModel.selected)) {
|
||||||
|
this.supportsZoom = !!(newTimeSystem.defaults() && newTimeSystem.defaults().zoom);
|
||||||
this.setFormFromTimeSystem(newTimeSystem);
|
this.setFormFromTimeSystem(newTimeSystem);
|
||||||
|
|
||||||
if (newTimeSystem.defaults()) {
|
if (newTimeSystem.defaults()) {
|
||||||
|
@ -178,6 +178,28 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
expect(mockScope.timeSystemModel.maxZoom).toBe(mockDefaults.zoom.max);
|
expect(mockScope.timeSystemModel.maxZoom).toBe(mockDefaults.zoom.max);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("supports zoom if time system defines zoom defaults", function () {
|
||||||
|
|
||||||
|
mockDefaults.zoom = undefined;
|
||||||
|
|
||||||
|
tsListener(timeSystem);
|
||||||
|
expect(controller.supportsZoom).toBe(false);
|
||||||
|
|
||||||
|
mockDefaults.zoom = {
|
||||||
|
min: 100,
|
||||||
|
max: 10
|
||||||
|
};
|
||||||
|
|
||||||
|
var anotherTimeSystem = Object.create(timeSystem);
|
||||||
|
timeSystem.defaults = function () {
|
||||||
|
return mockDefaults;
|
||||||
|
};
|
||||||
|
|
||||||
|
tsListener(anotherTimeSystem);
|
||||||
|
expect(controller.supportsZoom).toBe(true);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it("when bounds change, sets the correct zoom slider value", function () {
|
it("when bounds change, sets the correct zoom slider value", function () {
|
||||||
var bounds = {
|
var bounds = {
|
||||||
start: 0,
|
start: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user