[Time Conductor] Restore last valid values

Restore last valid values on blur, in a date-time entry field.
This commit is contained in:
Victor Woeltjen 2015-11-25 11:12:41 -08:00
parent 976ecce075
commit 1ef09ffbdd
2 changed files with 10 additions and 1 deletions

View File

@ -2,7 +2,7 @@
ng-controller="DateTimeFieldController">
<input type="text"
ng-model="textValue"
ng-blur="structure.submit()"
ng-blur="restoreValue(); structure.submit()"
ng-class="{ error: textInvalid }">
</input>
<a class="ui-symbol icon icon-calendar"

View File

@ -53,6 +53,7 @@ define(
formatter.parse($scope.textValue) !== value) {
$scope.textValue = formatter.format(value);
$scope.textInvalid = false;
$scope.lastValidValue = $scope.textValue;
}
}
@ -61,6 +62,7 @@ define(
if (!$scope.textInvalid) {
$scope.ngModel[$scope.field] =
formatter.parse(textValue);
$scope.lastValidValue = $scope.textValue;
}
}
@ -69,6 +71,13 @@ define(
updateFromModel($scope.ngModel[$scope.field]);
}
function restoreValue() {
$scope.textValue = $scope.lastValidValue;
updateFromView($scope.textValue);
}
$scope.restoreValue = restoreValue;
$scope.picker = { active: false };
$scope.$watch('structure.format', setFormat);