Detect "backwards" shift when time sheet is edited, alert user
This commit is contained in:
parent
27903b5984
commit
04e9752ee1
|
@ -146,12 +146,24 @@ function update_row_hours(row) {
|
|||
function cleanup_editor_input() {
|
||||
// TODO: is this hacky? invoking timepicker to format the time values
|
||||
// in all cases, to avoid "invalid format" from user input
|
||||
var backward = false;
|
||||
$('#day-editor .shifts .shift').each(function() {
|
||||
var start_time = $(this).children('input[name|="edit_start_time"]');
|
||||
var end_time = $(this).children('input[name|="edit_end_time"]');
|
||||
$.timepicker._setTime(start_time.data('timepicker'), start_time.val() || '??');
|
||||
$.timepicker._setTime(end_time.data('timepicker'), end_time.val() || '??');
|
||||
var t_start = parseTime(start_time.val());
|
||||
var t_end = parseTime(end_time.val());
|
||||
if (t_start && t_end) {
|
||||
if ((t_start.hh > t_end.hh) || ((t_start.hh == t_end.hh) && (t_start.mm > t_end.mm))) {
|
||||
alert("Start time falls *after* end time! Please fix...");
|
||||
start_time.focus().select();
|
||||
backward = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
return !backward;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,12 @@
|
|||
{
|
||||
text: "Save Changes",
|
||||
click: function(event) {
|
||||
if (cleanup_editor_input()) {
|
||||
$(event.target).button('disable').button('option', 'label', "Saving...");
|
||||
cleanup_editor_input();
|
||||
update_timetable();
|
||||
$('#timetable-form').submit();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Cancel",
|
||||
|
|
Loading…
Reference in a new issue