mirror of
https://github.com/nasa/openmct.git
synced 2025-06-06 01:11:41 +00:00
[Time Conductor] Change format handling
Use default format when no format is specified, and throw an error when a specified format is unrecognized, from both date-time field controller and time range controller.
This commit is contained in:
parent
4f9a65a5fe
commit
7f571415dc
@ -53,7 +53,7 @@
|
|||||||
{
|
{
|
||||||
"key": "TimeRangeController",
|
"key": "TimeRangeController",
|
||||||
"implementation": "controllers/TimeRangeController.js",
|
"implementation": "controllers/TimeRangeController.js",
|
||||||
"depends": [ "$scope", "formatService", "now" ]
|
"depends": [ "$scope", "formatService", "DEFAULT_TIME_FORMAT", "now" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "DateTimePickerController",
|
"key": "DateTimePickerController",
|
||||||
@ -63,7 +63,7 @@
|
|||||||
{
|
{
|
||||||
"key": "DateTimeFieldController",
|
"key": "DateTimeFieldController",
|
||||||
"implementation": "controllers/DateTimeFieldController.js",
|
"implementation": "controllers/DateTimeFieldController.js",
|
||||||
"depends": [ "$scope", "formatService" ]
|
"depends": [ "$scope", "formatService", "DEFAULT_TIME_FORMAT" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "TreeNodeController",
|
"key": "TreeNodeController",
|
||||||
|
@ -26,7 +26,8 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var DEFAULT_FORMAT = 'utc';
|
var UNRECOGNIZED_FORMAT_ERROR =
|
||||||
|
"Unrecognized format for date-time field.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller to support the date-time entry field.
|
* Controller to support the date-time entry field.
|
||||||
@ -40,12 +41,14 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @memberof platform/commonUI/general
|
* @memberof platform/commonUI/general
|
||||||
*/
|
*/
|
||||||
function DateTimeFieldController($scope, formatService) {
|
function DateTimeFieldController($scope, formatService, defaultFormat) {
|
||||||
var formatter = formatService.getFormat(DEFAULT_FORMAT);
|
var formatter = formatService.getFormat(defaultFormat);
|
||||||
|
|
||||||
function setFormat(format) {
|
function setFormat(format) {
|
||||||
formatter = formatService.getFormat(format) ||
|
formatter = formatService.getFormat(format || defaultFormat);
|
||||||
formatService.getFormat(DEFAULT_FORMAT);
|
if (!formatter) {
|
||||||
|
throw new Error(UNRECOGNIZED_FORMAT_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFromModel(value) {
|
function updateFromModel(value) {
|
||||||
|
@ -26,20 +26,22 @@ define(
|
|||||||
function (moment) {
|
function (moment) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var DEFAULT_FORMAT = "utc",
|
var TICK_SPACING_PX = 150,
|
||||||
TICK_SPACING_PX = 150;
|
UNRECOGNIZED_FORMAT_ERROR =
|
||||||
|
"Unrecognized format for time range control.";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller used by the `time-controller` template.
|
* Controller used by the `time-controller` template.
|
||||||
* @memberof platform/commonUI/general
|
* @memberof platform/commonUI/general
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function TimeRangeController($scope, formatService, now) {
|
function TimeRangeController($scope, formatService, defaultFormat, now) {
|
||||||
var tickCount = 2,
|
var tickCount = 2,
|
||||||
innerMinimumSpan = 1000, // 1 second
|
innerMinimumSpan = 1000, // 1 second
|
||||||
outerMinimumSpan = 1000 * 60 * 60, // 1 hour
|
outerMinimumSpan = 1000 * 60 * 60, // 1 hour
|
||||||
initialDragValue,
|
initialDragValue,
|
||||||
formatter = formatService.getFormat(DEFAULT_FORMAT);
|
formatter = formatService.getFormat(defaultFormat);
|
||||||
|
|
||||||
function formatTimestamp(ts) {
|
function formatTimestamp(ts) {
|
||||||
return formatter.format(ts);
|
return formatter.format(ts);
|
||||||
@ -212,8 +214,11 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateFormat(key) {
|
function updateFormat(key) {
|
||||||
formatter = formatService.getFormat(key) ||
|
formatter = formatService.getFormat(key || defaultFormat);
|
||||||
formatService.getFormat(DEFAULT_FORMAT);
|
|
||||||
|
if (!formatter) {
|
||||||
|
throw new Error(UNRECOGNIZED_FORMAT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
updateViewForInnerSpanFromModel($scope.ngModel);
|
updateViewForInnerSpanFromModel($scope.ngModel);
|
||||||
updateTicks();
|
updateTicks();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user