Skip to content

Commit

Permalink
ATLDEV-323 Add check if the time format is correct
Browse files Browse the repository at this point in the history
ATLDEV-323 remove debugger
  • Loading branch information
Brunner-Leo committed Aug 16, 2021
1 parent f4f6351 commit 259183d
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/main/resources/js/timesheet/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var savingError;
var ppFlag;
var dateRangeFlag;
var dateFlag;
var timeStartFlag;
var timeEndFlag;
var descrFlag;
var pauseFlag;

Expand Down Expand Up @@ -405,6 +407,14 @@ function prepareForm(entry, timesheetData, isModified) {
form.saveButton.prop('disabled', false);
});

form.beginTimeField.change(function () {
form.saveButton.prop('disabled', false);
});

form.endTimeField.change(function () {
form.saveButton.prop('disabled', false);
});

row.find('input.time.start, input.time.end')
.timepicker({
showDuration: false,
Expand Down Expand Up @@ -1120,17 +1130,41 @@ function submit(timesheetData, saveOptions, form, existingEntryID,
if ((date == "") || (!isValidDate(validDateFormat))) {
date = new Date().toJSON().slice(0, 10);
}

var beginTime = form.beginTimeField.timepicker('getTime');

if (beginTime === null) {
beginTime = new Date();
if (timeStartFlag)
timeStartFlag.close();
timeStartFlag = AJS.flag({
type: 'warning',
title: 'Invalid start time format',
body: 'The start time should be a valid time.',
close: 'auto'
});

form.beginTimeField.css({
"border-color": "red"
});
return;
}

var endTime = form.endTimeField.timepicker('getTime');

if (endTime === null) {
endTime = new Date();
if (timeStartFlag)
timeStartFlag.close();
timeStartFlag = AJS.flag({
type: 'warning',
title: 'Invalid end time format',
body: 'The end time should be a valid time.',
close: 'auto'
});

form.endTimeField.css({
"border-color": "red"
});
return;
}

date = date.replace(/-/g, "/");
Expand Down

0 comments on commit 259183d

Please sign in to comment.