Skip to content

Commit

Permalink
Check for date validity in preview (linkedin#196)
Browse files Browse the repository at this point in the history
* prevent invalid date selection

* added on eventalways
  • Loading branch information
diegocepedaw authored and dwang159 committed Aug 6, 2018
1 parent fe57a49 commit 53a72b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/oncall/ui/static/js/incalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
onEventGet: function (data, $calendar) {
// callback for when fetch events ajax call is completed. list of events from server is passed in as arg
},
onEventAlways: function(){
// callback for when fetch events ajax call is completed run regardless of success or failure
},
onAddEvents: function (events) {
// callback for when events are added to calendar
},
Expand Down Expand Up @@ -678,6 +681,7 @@
self.options.onEventGet(data, self.$calendar);
}).always(function(){
self.$el.removeClass('loading-events');
self.options.onEventAlways();
});
},
addCalendarEvents: function (eventsArray) {
Expand Down
4 changes: 4 additions & 0 deletions src/oncall/ui/static/js/oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,8 @@ var oncall = {

if ( isNaN(Date.parse(date)) ) {
oncall.alerts.createAlert('Invalid date.', 'danger', $modal.find('.modal-body'));
} else if (date <= new Date()) {
oncall.alerts.createAlert('Invalid date. Can only preview events in the future.', 'danger', $modal.find('.modal-body'));
} else {
self.populatePreview(date.valueOf(), $(this), $modal);
}
Expand Down Expand Up @@ -2290,6 +2292,8 @@ var oncall = {
readOnly: true,
onEventGet: function(events, $cal){
$cal.find('[data-schedule-id="' + scheduleId + '"]').attr('data-highlighted', true);
},
onEventAlways: function(){
$cta.removeClass('loading disabled').prop('disabled', false);
}
});
Expand Down

0 comments on commit 53a72b0

Please sign in to comment.