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">
<mct-control key="'datetime-field'"
structure="{
format: 'utc',
format: timeSystemModel.format,
validate: tcController.validation.validateStart
}"
ng-model="formModel"
@ -59,7 +59,7 @@
ng-controller="ToggleController as t2">
<mct-control key="'datetime-field'"
structure="{
format: 'utc',
format: timeSystemModel.format,
validate: tcController.validation.validateEnd
}"
ng-model="formModel"

View File

@ -22,8 +22,7 @@
define([
'./TimeSystem',
'./LocalClock',
'../../../../commonUI/formats/src/UTCTimeFormat'
'./LocalClock'
], function (TimeSystem, LocalClock, UTCTimeFormat) {
var FIFTEEN_MINUTES = 15 * 60 * 1000,
DEFAULT_PERIOD = 1000;
@ -36,13 +35,20 @@ define([
function UTCTimeSystem ($timeout) {
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 = {
'key': 'utc',
'name': 'UTC',
'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)];
}

View File

@ -72,6 +72,7 @@ define(
TimeConductorController.prototype.initializeScope = function ($scope) {
$scope.timeSystemModel = {
selected: undefined,
format: undefined,
options: []
};
$scope.modeModel = {
@ -155,13 +156,17 @@ define(
}
newMode.initialize();
var timeSystem = newMode.selectedTimeSystem();
this.$scope.modeModel.selected = newMode;
//Synchronize scope with time system on mode
this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) {
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());
}
};