diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js index b0ba5e0eee7..a81558c48e6 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js @@ -99,6 +99,7 @@ define( if (this.conductor.timeSystem()) { $scope.timeSystemModel.selected = this.conductor.timeSystem(); $scope.timeSystemModel.format = this.conductor.timeSystem().formats()[0]; + $scope.timeSystemModel.deltaFormat = this.conductor.timeSystem().deltaFormat(); } /* @@ -194,6 +195,9 @@ define( TimeConductorController.prototype.setMode = function (newModeKey, oldModeKey) { if (newModeKey !== oldModeKey) { var newMode = undefined; + var timeSystems = []; + var timeSystem = undefined; + this.$scope.modeModel.selectedKey = newModeKey; if (this.conductorService.mode()) { @@ -202,26 +206,31 @@ define( switch (newModeKey) { case 'fixed': - newMode = new FixedMode(this.conductor, this._timeSystems, newModeKey); + timeSystems = this._timeSystems; + timeSystem = timeSystems[0]; + newMode = new FixedMode(this.conductor, timeSystem, newModeKey); break; case 'realtime': // Filter time systems to only those with clock tick // sources - newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'), newModeKey); + timeSystems = this.timeSystemsForSourceType('clock'); + timeSystem = timeSystems[0]; + newMode = new FollowMode(this.conductor, timeSystem, newModeKey); break; case 'latest': // Filter time systems to only those with data tick // sources - newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'), newModeKey); + timeSystems = this.timeSystemsForSourceType('data'); + timeSystem = timeSystems[0]; + newMode = new FollowMode(this.conductor, timeSystem, newModeKey); break; } newMode.initialize(); this.conductorService.mode(newMode); - var timeSystem = newMode.selectedTimeSystem(); //Synchronize scope with time system on mode - this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) { - return timeSystem.metadata; + this.$scope.timeSystemModel.options = timeSystems.map(function (t) { + return t.metadata; }); this.setTimeSystem(timeSystem); @@ -272,7 +281,7 @@ define( this.$scope.timeSystemModel.format = newTimeSystem.formats()[0]; this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat(); var mode = this.conductorService.mode(); - mode.selectedTimeSystem(newTimeSystem); + mode.timeSystem(newTimeSystem); this.setDeltasFromTimeSystem(newTimeSystem); } }; diff --git a/platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js b/platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js index 06750459c97..f395c1456bc 100644 --- a/platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js +++ b/platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js @@ -32,8 +32,8 @@ define( * @param timeSystems * @constructor */ - function FixedMode(conductor, timeSystems, key) { - TimeConductorMode.call(this, conductor, timeSystems, key); + function FixedMode(conductor, timeSystem, key) { + TimeConductorMode.call(this, conductor, timeSystem, key); } FixedMode.prototype = Object.create(TimeConductorMode.prototype); @@ -49,8 +49,8 @@ define( * @param timeSystem * @returns {*} */ - FixedMode.prototype.selectedTimeSystem = function (timeSystem){ - TimeConductorMode.prototype.selectedTimeSystem.apply(this, arguments); + FixedMode.prototype.timeSystem = function (timeSystem){ + TimeConductorMode.prototype.timeSystem.apply(this, arguments); if (timeSystem) { var defaults = timeSystem.defaults()[0]; @@ -62,7 +62,7 @@ define( this.conductor.timeSystem(timeSystem, bounds); } - return this._selectedTimeSystem; + return this._timeSystem; }; return FixedMode; diff --git a/platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js b/platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js index 8385a170690..fc6a2a8ba93 100644 --- a/platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js +++ b/platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js @@ -33,8 +33,8 @@ define( * the mode relevant, with both offsets defined relative to it. * @constructor */ - function FollowMode(conductor, timeSystems, key) { - TimeConductorMode.call(this, conductor, timeSystems, key); + function FollowMode(conductor, timeSystem, key) { + TimeConductorMode.call(this, conductor, timeSystem, key); this._deltas = undefined; } @@ -63,10 +63,8 @@ define( * @param tickSource */ FollowMode.prototype.listenToTickSource = function () { - if (this._selectedTimeSystem && - this._timeSystems[0]) { - - var tickSource = this._timeSystems[0].tickSources()[0]; + if (this._timeSystem) { + var tickSource = this._timeSystem.tickSources()[0]; if (tickSource) { this.tickSourceUnlisten = tickSource.listen(this.tick.bind(this)); } @@ -79,8 +77,8 @@ define( * @param timeSystem * @returns {TimeSystem} */ - FollowMode.prototype.selectedTimeSystem = function (timeSystem) { - TimeConductorMode.prototype.selectedTimeSystem.apply(this, arguments); + FollowMode.prototype.timeSystem = function (timeSystem) { + TimeConductorMode.prototype.timeSystem.apply(this, arguments); if (timeSystem) { if (this.tickSourceUnlisten) { @@ -106,7 +104,7 @@ define( this.listenToTickSource(); } } - return this._selectedTimeSystem; + return this._timeSystem; }; /** diff --git a/platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js b/platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js index f4bd0526c4f..dfc683e4180 100644 --- a/platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js +++ b/platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js @@ -33,9 +33,9 @@ define( * @constructor * @param {TimeConductorMetadata} metadata */ - function TimeConductorMode(conductor, timeSystems, key) { + function TimeConductorMode(conductor, timeSystem, key) { this.conductor = conductor; - this._timeSystems = timeSystems; + this._timeSystem = timeSystem; this._key = key; } @@ -43,18 +43,7 @@ define( * Function is called when mode becomes active (ie. is selected) */ TimeConductorMode.prototype.initialize = function () { - this.selectedTimeSystem(this._timeSystems[0]); - }; - - /** - * Return the time systems supported by this mode. Modes are - * expected to determine which time systems they will support by - * filtering a provided list of all time systems. - * - * @returns {TimeSystem[]} The time systems supported by this mode - */ - TimeConductorMode.prototype.timeSystems = function () { - return this._timeSystems; + this.timeSystem(this._timeSystem); }; /** @@ -62,15 +51,11 @@ define( * @param timeSystem * @returns {TimeSystem} the currently selected time system */ - TimeConductorMode.prototype.selectedTimeSystem = function (timeSystem) { + TimeConductorMode.prototype.timeSystem = function (timeSystem) { if (arguments.length > 0) { - if (this._timeSystems.indexOf(timeSystem) === -1){ - throw new Error("Unsupported time system"); - } else { - this._selectedTimeSystem = timeSystem; - } + this._timeSystem = timeSystem; } - return this._selectedTimeSystem; + return this._timeSystem; }; TimeConductorMode.prototype.key = function () {