Auto-save time sheet day editor on Enter press if time field is focused

Hopefully this is a good idea, may have to revisit someday..?
This commit is contained in:
Lance Edgar 2017-04-17 16:24:34 -05:00
parent 56aff60efd
commit 589a747662
2 changed files with 29 additions and 7 deletions

View file

@ -212,6 +212,21 @@ function update_timetable() {
} }
/**
* Perform full "save" action for time sheet form, direct from day editor dialog.
*/
function save_dialog() {
if (! cleanup_editor_input()) {
return false;
}
var save = $('#day-editor').parents('.ui-dialog').find('.ui-dialog-buttonpane button:first');
save.button('disable').button('option', 'label', "Saving...");
update_timetable();
$('#timetable-form').submit();
return true;
}
/* /*
* on document load... * on document load...
*/ */
@ -233,4 +248,17 @@ $(function() {
$(this).parents('.shift:first').remove(); $(this).parents('.shift:first').remove();
}); });
/*
* Within editor dialog, Enter press within time field "might" trigger
* save. Note that this is only done for timesheet editing, not schedule.
*/
$('#day-editor').on('keydown', '.shifts input[type="text"]', function(event) {
if (!show_timepicker) { // TODO: this implies too much, should be cleaner
if (event.which == 13) {
save_dialog();
return false;
}
}
});
}); });

View file

@ -36,13 +36,7 @@
buttons: [ buttons: [
{ {
text: "Save Changes", text: "Save Changes",
click: function(event) { click: save_dialog
if (cleanup_editor_input()) {
$(event.target).button('disable').button('option', 'label', "Saving...");
update_timetable();
$('#timetable-form').submit();
}
}
}, },
{ {
text: "Cancel", text: "Cancel",