mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 06:08:11 +00:00
[Time Conductor] Update text on format change
...in a date-time field.
This commit is contained in:
@ -44,13 +44,6 @@ define(
|
|||||||
function DateTimeFieldController($scope, formatService, defaultFormat) {
|
function DateTimeFieldController($scope, formatService, defaultFormat) {
|
||||||
var formatter = formatService.getFormat(defaultFormat);
|
var formatter = formatService.getFormat(defaultFormat);
|
||||||
|
|
||||||
function setFormat(format) {
|
|
||||||
formatter = formatService.getFormat(format || defaultFormat);
|
|
||||||
if (!formatter) {
|
|
||||||
throw new Error(UNRECOGNIZED_FORMAT_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateFromModel(value) {
|
function updateFromModel(value) {
|
||||||
// Only reformat if the value is different from user
|
// Only reformat if the value is different from user
|
||||||
// input (to avoid reformatting valid input while typing.)
|
// input (to avoid reformatting valid input while typing.)
|
||||||
@ -69,6 +62,14 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setFormat(format) {
|
||||||
|
formatter = formatService.getFormat(format || defaultFormat);
|
||||||
|
if (!formatter) {
|
||||||
|
throw new Error(UNRECOGNIZED_FORMAT_ERROR);
|
||||||
|
}
|
||||||
|
updateFromModel($scope.ngModel[$scope.field]);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$watch('structure.format', setFormat);
|
$scope.$watch('structure.format', setFormat);
|
||||||
$scope.$watch('ngModel[field]', updateFromModel);
|
$scope.$watch('ngModel[field]', updateFromModel);
|
||||||
$scope.$watch('textValue', updateFromView);
|
$scope.$watch('textValue', updateFromView);
|
||||||
|
Reference in New Issue
Block a user