Skip to content

Commit 579233a

Browse files
committed
Fixed delta format issue on navigation
1 parent f4e1879 commit 579233a

File tree

4 files changed

+34
-42
lines changed

4 files changed

+34
-42
lines changed

platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ define(
9999
if (this.conductor.timeSystem()) {
100100
$scope.timeSystemModel.selected = this.conductor.timeSystem();
101101
$scope.timeSystemModel.format = this.conductor.timeSystem().formats()[0];
102+
$scope.timeSystemModel.deltaFormat = this.conductor.timeSystem().deltaFormat();
102103
}
103104

104105
/*
@@ -194,6 +195,9 @@ define(
194195
TimeConductorController.prototype.setMode = function (newModeKey, oldModeKey) {
195196
if (newModeKey !== oldModeKey) {
196197
var newMode = undefined;
198+
var timeSystems = [];
199+
var timeSystem = undefined;
200+
197201
this.$scope.modeModel.selectedKey = newModeKey;
198202

199203
if (this.conductorService.mode()) {
@@ -202,26 +206,31 @@ define(
202206

203207
switch (newModeKey) {
204208
case 'fixed':
205-
newMode = new FixedMode(this.conductor, this._timeSystems, newModeKey);
209+
timeSystems = this._timeSystems;
210+
timeSystem = timeSystems[0];
211+
newMode = new FixedMode(this.conductor, timeSystem, newModeKey);
206212
break;
207213
case 'realtime':
208214
// Filter time systems to only those with clock tick
209215
// sources
210-
newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'), newModeKey);
216+
timeSystems = this.timeSystemsForSourceType('clock');
217+
timeSystem = timeSystems[0];
218+
newMode = new FollowMode(this.conductor, timeSystem, newModeKey);
211219
break;
212220
case 'latest':
213221
// Filter time systems to only those with data tick
214222
// sources
215-
newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'), newModeKey);
223+
timeSystems = this.timeSystemsForSourceType('data');
224+
timeSystem = timeSystems[0];
225+
newMode = new FollowMode(this.conductor, timeSystem, newModeKey);
216226
break;
217227
}
218228
newMode.initialize();
219229
this.conductorService.mode(newMode);
220-
var timeSystem = newMode.selectedTimeSystem();
221230

222231
//Synchronize scope with time system on mode
223-
this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) {
224-
return timeSystem.metadata;
232+
this.$scope.timeSystemModel.options = timeSystems.map(function (t) {
233+
return t.metadata;
225234
});
226235

227236
this.setTimeSystem(timeSystem);
@@ -272,7 +281,7 @@ define(
272281
this.$scope.timeSystemModel.format = newTimeSystem.formats()[0];
273282
this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat();
274283
var mode = this.conductorService.mode();
275-
mode.selectedTimeSystem(newTimeSystem);
284+
mode.timeSystem(newTimeSystem);
276285
this.setDeltasFromTimeSystem(newTimeSystem);
277286
}
278287
};

platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ define(
3232
* @param timeSystems
3333
* @constructor
3434
*/
35-
function FixedMode(conductor, timeSystems, key) {
36-
TimeConductorMode.call(this, conductor, timeSystems, key);
35+
function FixedMode(conductor, timeSystem, key) {
36+
TimeConductorMode.call(this, conductor, timeSystem, key);
3737
}
3838

3939
FixedMode.prototype = Object.create(TimeConductorMode.prototype);
@@ -49,8 +49,8 @@ define(
4949
* @param timeSystem
5050
* @returns {*}
5151
*/
52-
FixedMode.prototype.selectedTimeSystem = function (timeSystem){
53-
TimeConductorMode.prototype.selectedTimeSystem.apply(this, arguments);
52+
FixedMode.prototype.timeSystem = function (timeSystem){
53+
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
5454

5555
if (timeSystem) {
5656
var defaults = timeSystem.defaults()[0];
@@ -62,7 +62,7 @@ define(
6262

6363
this.conductor.timeSystem(timeSystem, bounds);
6464
}
65-
return this._selectedTimeSystem;
65+
return this._timeSystem;
6666
};
6767

6868
return FixedMode;

platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ define(
3333
* the mode relevant, with both offsets defined relative to it.
3434
* @constructor
3535
*/
36-
function FollowMode(conductor, timeSystems, key) {
37-
TimeConductorMode.call(this, conductor, timeSystems, key);
36+
function FollowMode(conductor, timeSystem, key) {
37+
TimeConductorMode.call(this, conductor, timeSystem, key);
3838

3939
this._deltas = undefined;
4040
}
@@ -63,10 +63,8 @@ define(
6363
* @param tickSource
6464
*/
6565
FollowMode.prototype.listenToTickSource = function () {
66-
if (this._selectedTimeSystem &&
67-
this._timeSystems[0]) {
68-
69-
var tickSource = this._timeSystems[0].tickSources()[0];
66+
if (this._timeSystem) {
67+
var tickSource = this._timeSystem.tickSources()[0];
7068
if (tickSource) {
7169
this.tickSourceUnlisten = tickSource.listen(this.tick.bind(this));
7270
}
@@ -79,8 +77,8 @@ define(
7977
* @param timeSystem
8078
* @returns {TimeSystem}
8179
*/
82-
FollowMode.prototype.selectedTimeSystem = function (timeSystem) {
83-
TimeConductorMode.prototype.selectedTimeSystem.apply(this, arguments);
80+
FollowMode.prototype.timeSystem = function (timeSystem) {
81+
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
8482

8583
if (timeSystem) {
8684
if (this.tickSourceUnlisten) {
@@ -106,7 +104,7 @@ define(
106104
this.listenToTickSource();
107105
}
108106
}
109-
return this._selectedTimeSystem;
107+
return this._timeSystem;
110108
};
111109

112110
/**

platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js

+6-21
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,29 @@ define(
3333
* @constructor
3434
* @param {TimeConductorMetadata} metadata
3535
*/
36-
function TimeConductorMode(conductor, timeSystems, key) {
36+
function TimeConductorMode(conductor, timeSystem, key) {
3737
this.conductor = conductor;
38-
this._timeSystems = timeSystems;
38+
this._timeSystem = timeSystem;
3939
this._key = key;
4040
}
4141

4242
/**
4343
* Function is called when mode becomes active (ie. is selected)
4444
*/
4545
TimeConductorMode.prototype.initialize = function () {
46-
this.selectedTimeSystem(this._timeSystems[0]);
47-
};
48-
49-
/**
50-
* Return the time systems supported by this mode. Modes are
51-
* expected to determine which time systems they will support by
52-
* filtering a provided list of all time systems.
53-
*
54-
* @returns {TimeSystem[]} The time systems supported by this mode
55-
*/
56-
TimeConductorMode.prototype.timeSystems = function () {
57-
return this._timeSystems;
46+
this.timeSystem(this._timeSystem);
5847
};
5948

6049
/**
6150
* Get or set the currently selected time system
6251
* @param timeSystem
6352
* @returns {TimeSystem} the currently selected time system
6453
*/
65-
TimeConductorMode.prototype.selectedTimeSystem = function (timeSystem) {
54+
TimeConductorMode.prototype.timeSystem = function (timeSystem) {
6655
if (arguments.length > 0) {
67-
if (this._timeSystems.indexOf(timeSystem) === -1){
68-
throw new Error("Unsupported time system");
69-
} else {
70-
this._selectedTimeSystem = timeSystem;
71-
}
56+
this._timeSystem = timeSystem;
7257
}
73-
return this._selectedTimeSystem;
58+
return this._timeSystem;
7459
};
7560

7661
TimeConductorMode.prototype.key = function () {

0 commit comments

Comments
 (0)