Merge pull request #7106 from gconsidine/ui/fix/scheduler-time-input

Fix scheduler time inputs by resetting invalid input to 00
This commit is contained in:
Greg Considine 2017-07-18 10:19:16 -04:00 committed by GitHub
commit 93f28c760c
3 changed files with 52 additions and 3 deletions

View File

@ -25,6 +25,31 @@ export default ['$filter', '$state', '$stateParams', 'AddSchedule', 'Wait',
$scope.schedulerEndSecond = "00";
$scope.parentObject = ParentObject;
/*
* This is a workaround for the angular-scheduler library inserting `ll` into fields after an
* invalid entry and never unsetting them. Presumably null is being truncated down to 2 chars
* in that case.
*
* Because this same problem exists in the edit mode and because there's no inheritence, this
* block of code is duplicated in both add/edit controllers pending a much needed broader
* refactoring effort.
*/
$scope.timeChange = () => {
if (!Number($scope.schedulerStartHour)) {
$scope.schedulerStartHour = '00';
}
if (!Number($scope.schedulerStartMinute)) {
$scope.schedulerStartMinute = '00';
}
if (!Number($scope.schedulerStartSecond)) {
$scope.schedulerStartSecond = '00';
}
$scope.scheduleTimeChange();
};
$scope.$on("ScheduleFormCreated", function(e, scope) {
$scope.hideForm = false;
$scope = angular.extend($scope, scope);

View File

@ -16,6 +16,30 @@ function($filter, $state, $stateParams, EditSchedule, Wait, $scope, $rootScope,
$scope.schedulerEndSecond = "00";
$scope.parentObject = ParentObject;
/*
* This is a workaround for the angular-scheduler library inserting `ll` into fields after an
* invalid entry and never unsetting them. Presumably null is being truncated down to 2 chars
* in that case.
*
* Because this same problem exists in the edit mode and because there's no inheritence, this
* block of code is duplicated in both add/edit controllers pending a much needed broader
* refactoring effort.
*/
$scope.timeChange = () => {
if (!Number($scope.schedulerStartHour)) {
$scope.schedulerStartHour = '00';
}
if (!Number($scope.schedulerStartMinute)) {
$scope.schedulerStartMinute = '00';
}
if (!Number($scope.schedulerStartSecond)) {
$scope.schedulerStartSecond = '00';
}
$scope.scheduleTimeChange();
};
$scope.$on("ScheduleFormCreated", function(e, scope) {
$scope.hideForm = false;

View File

@ -75,7 +75,7 @@
placeholder="HH24"
aw-min="0" min="0" aw-max="23"
max="23" data-zero-pad="2" required
ng-change="scheduleTimeChange()" >
ng-change="timeChange()" >
<span
class="SchedulerTime-separator">
:
@ -91,7 +91,7 @@
placeholder="MM"
min="0" max="59" data-zero-pad="2"
required
ng-change="scheduleTimeChange()" >
ng-change="timeChange()" >
<span
class="SchedulerTime-separator">
:
@ -107,7 +107,7 @@
placeholder="SS"
min="0" max="59" data-zero-pad="2"
required
ng-change="scheduleTimeChange()" >
ng-change="timeChange()" >
</div>
<div class="error"
ng-show="scheduler_startTime_error">