Merge pull request #2015 from marshmalien/fix/1970-1885-scheduler-bugs

Fix invalid schedule warning and disable save button
This commit is contained in:
Marliana Lara
2018-06-01 10:04:29 -04:00
committed by GitHub
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; $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 // set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight
var dt = new Date($scope.schedulerUTCTime); var dt = new Date($scope.schedulerUTCTime);
// increment date by 1 day // increment date by 1 day
@@ -329,7 +334,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
}); });
if ($scope.schedulerUTCTime) { if ($scope.schedulerUTCTime) {
// The UTC time is already set // The UTC time is already set
processSchedulerEndDt(); $scope.processSchedulerEndDt();
} else { } else {
// We need to wait for it to be set by angular-scheduler because the following function depends // We need to wait for it to be set by angular-scheduler because the following function depends
// on it // on it
@@ -337,7 +342,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
if (newVal) { if (newVal) {
// Remove the watcher // Remove the watcher
schedulerUTCTimeWatcher(); schedulerUTCTimeWatcher();
processSchedulerEndDt(); $scope.processSchedulerEndDt();
} }
}); });
} }
@@ -370,9 +375,6 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
scheduler.clear(); scheduler.clear();
$scope.$on("htmlDetailReady", function() { $scope.$on("htmlDetailReady", function() {
$scope.hideForm = false; $scope.hideForm = false;
$scope.$on("formUpdated", function() {
$rootScope.$broadcast("loadSchedulerDetailPane");
});
$scope.$watchGroup(["schedulerName", $scope.$watchGroup(["schedulerName",
"schedulerStartDt", "schedulerStartDt",
"schedulerStartHour", "schedulerStartHour",
@@ -398,11 +400,11 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
"schedulerEndMinute", "schedulerEndMinute",
"schedularEndSecond" "schedularEndSecond"
], function() { ], function() {
$scope.$emit("formUpdated"); $rootScope.$broadcast("loadSchedulerDetailPane");
}, true); }, true);
$scope.$watch("weekDays", function() { $scope.$watch("weekDays", function() {
$scope.$emit("formUpdated"); $rootScope.$broadcast("loadSchedulerDetailPane");
}, true); }, true);
Wait('stop'); Wait('stop');

View File

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

View File

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