1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Fix scheduler form warning bug and disable save when date options are invalid

This commit is contained in:
Marliana Lara 2018-05-31 16:31:19 -04:00
parent 4c9ceb48a1
commit 2bdb1fc577
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 15 additions and 9 deletions

View File

@ -30,7 +30,12 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
$scope.canAdd = params.canAdd;
});
}
let processSchedulerEndDt = function(){
/*
* Keep processSchedulerEndDt method on the $scope
* because angular-scheduler references it
*/
$scope.processSchedulerEndDt = function(){
// set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight
var dt = new Date($scope.schedulerUTCTime);
// increment date by 1 day
@ -329,7 +334,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
});
if ($scope.schedulerUTCTime) {
// The UTC time is already set
processSchedulerEndDt();
$scope.processSchedulerEndDt();
} else {
// We need to wait for it to be set by angular-scheduler because the following function depends
// on it
@ -337,7 +342,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
if (newVal) {
// Remove the watcher
schedulerUTCTimeWatcher();
processSchedulerEndDt();
$scope.processSchedulerEndDt();
}
});
}
@ -370,9 +375,6 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
scheduler.clear();
$scope.$on("htmlDetailReady", function() {
$scope.hideForm = false;
$scope.$on("formUpdated", function() {
$rootScope.$broadcast("loadSchedulerDetailPane");
});
$scope.$watchGroup(["schedulerName",
"schedulerStartDt",
"schedulerStartHour",
@ -398,11 +400,11 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
"schedulerEndMinute",
"schedularEndSecond"
], function() {
$scope.$emit("formUpdated");
$rootScope.$broadcast("loadSchedulerDetailPane");
}, true);
$scope.$watch("weekDays", function() {
$scope.$emit("formUpdated");
$rootScope.$broadcast("loadSchedulerDetailPane");
}, true);
Wait('stop');

View File

@ -23,6 +23,10 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
$scope.strings = TemplatesStrings;
/*
* Keep processSchedulerEndDt method on the $scope
* because angular-scheduler references it
*/
$scope.processSchedulerEndDt = function(){
// set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight
var dt = new Date($scope.schedulerUTCTime);

View File

@ -683,7 +683,7 @@
class="btn btn-sm Form-saveButton"
id="schedule_save_btn"
ng-click="saveSchedule()"
ng-disabled="!schedulerIsValid || promptModalMissingReqFields"> Save</button>
ng-disabled="!schedulerIsValid || promptModalMissingReqFields || (preview_list.isEmpty && scheduler_form.$dirty)"> Save</button>
</div>
</div>
<prompt prompt-data="promptData" action-text="{{:: strings.get('prompt.CONFIRM')}}" prevent-creds-with-passwords="preventCredsWithPasswords"></prompt>