Populate format in input fields

This commit is contained in:
Henry 2016-07-18 18:44:29 -07:00
parent 334ca64551
commit 15a608a861
3 changed files with 17 additions and 6 deletions

View File

@ -16,7 +16,7 @@
<span class="l-time-range-input-w start-date"> <span class="l-time-range-input-w start-date">
<mct-control key="'datetime-field'" <mct-control key="'datetime-field'"
structure="{ structure="{
format: 'utc', format: timeSystemModel.format,
validate: tcController.validation.validateStart validate: tcController.validation.validateStart
}" }"
ng-model="formModel" ng-model="formModel"
@ -59,7 +59,7 @@
ng-controller="ToggleController as t2"> ng-controller="ToggleController as t2">
<mct-control key="'datetime-field'" <mct-control key="'datetime-field'"
structure="{ structure="{
format: 'utc', format: timeSystemModel.format,
validate: tcController.validation.validateEnd validate: tcController.validation.validateEnd
}" }"
ng-model="formModel" ng-model="formModel"

View File

@ -22,8 +22,7 @@
define([ define([
'./TimeSystem', './TimeSystem',
'./LocalClock', './LocalClock'
'../../../../commonUI/formats/src/UTCTimeFormat'
], function (TimeSystem, LocalClock, UTCTimeFormat) { ], function (TimeSystem, LocalClock, UTCTimeFormat) {
var FIFTEEN_MINUTES = 15 * 60 * 1000, var FIFTEEN_MINUTES = 15 * 60 * 1000,
DEFAULT_PERIOD = 1000; DEFAULT_PERIOD = 1000;
@ -36,13 +35,20 @@ define([
function UTCTimeSystem ($timeout) { function UTCTimeSystem ($timeout) {
TimeSystem.call(this); TimeSystem.call(this);
/**
* Some metadata, which will be used to identify the time system in
* the UI
* @type {{key: string, name: string, glyph: string}}
*/
this.metadata = { this.metadata = {
'key': 'utc', 'key': 'utc',
'name': 'UTC', 'name': 'UTC',
'glyph': '\u0043' 'glyph': '\u0043'
}; };
this._formats = [new UTCTimeFormat()]; //Time formats are defined as extensions. Include the key
// for the corresponding time format here
this._formats = ['utc'];
this._tickSources = [new LocalClock($timeout, DEFAULT_PERIOD)]; this._tickSources = [new LocalClock($timeout, DEFAULT_PERIOD)];
} }

View File

@ -72,6 +72,7 @@ define(
TimeConductorController.prototype.initializeScope = function ($scope) { TimeConductorController.prototype.initializeScope = function ($scope) {
$scope.timeSystemModel = { $scope.timeSystemModel = {
selected: undefined, selected: undefined,
format: undefined,
options: [] options: []
}; };
$scope.modeModel = { $scope.modeModel = {
@ -155,13 +156,17 @@ define(
} }
newMode.initialize(); newMode.initialize();
var timeSystem = newMode.selectedTimeSystem();
this.$scope.modeModel.selected = newMode; this.$scope.modeModel.selected = newMode;
//Synchronize scope with time system on mode //Synchronize scope with time system on mode
this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) { this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) {
return timeSystem.metadata; return timeSystem.metadata;
}); });
this.$scope.timeSystemModel.selected = newMode.selectedTimeSystem(); this.$scope.timeSystemModel.selected = timeSystem;
//Use default format
this.$scope.timeSystemModel.format = timeSystem.formats()[0];
this.setDefaultsFromTimeSystem(newMode.selectedTimeSystem()); this.setDefaultsFromTimeSystem(newMode.selectedTimeSystem());
} }
}; };