Skip to content

Commit

Permalink
#380 extend Time buttons tooltips & round to 15 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
Josias Polchau authored and KlausRicharz committed Jul 21, 2024
1 parent c82dcef commit f58075d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/main/webapp/dailyreport/showDailyReport.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,37 @@
form.submit();
}
function saveBreak(form) {
function roundMinutes(minutes) {
return Math.round(minutes/15)*15;
}
function getExtendTime(currentValue, time) {
var quittingTime= '<c:out value="${quittingtime}"></c:out>';
var quittingTimeArray=quittingTime.split(":");
var diff=[ time.getHours() - Number(quittingTimeArray[0]),
time.getMinutes()-Number(quittingTimeArray[1])];
var res= [ Number(currentValue[0])+diff[0],
roundMinutes(Number(currentValue[1])+diff[1])];
if (res[1]<0) res= [res[0]-1, 60-res[1]];
if (res[1]>=60) res= [res[0]+1, res[1]-60];
if (res[0]<0){
confirm("<bean:message key="main.timereport.extendTime.error.text" />");
return currentValue;
}
return res;
}
function saveBreak(form, time) {
if(time != null) {
var newValue=getExtendTime([form.selectedBreakHour.value, form.selectedBreakMinute.value], time)
if(newValue[0]>5){
newValue=[5,55];
confirm("<bean:message key="main.timereport.extendTime.error.text" />");
}
form.selectedBreakHour.value =newValue[0];
form.selectedBreakMinute.value = newValue[1];
}
form.action = "/do/ShowDailyReport?task=saveBreak";
form.submit();
}
Expand Down Expand Up @@ -456,6 +486,7 @@
</html:select>
<a href="#" onclick="saveBegin(findForm(this))" title="save start of work"><i class="bi bi-floppy"></i></a>
<a href="#" onclick="saveBegin(findForm(this),new Date())" title="set start of work to now"><i class="bi bi-watch"></i></a>
</nobr>
</td>
</tr>
Expand All @@ -476,6 +507,7 @@
</html:select>
<a href="#" onclick="saveBreak(findForm(this))" title="save break"><i class="bi bi-floppy"></i></a>
<a href="#" onclick="saveBreak(findForm(this),new Date())" title="extend break"><i class="bi bi-skip-end"></i></a>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -787,6 +819,8 @@
<!-- Bearbeiten -->
<td class="noBborderStyle report-options" align="center">
<button type="button" onclick="confirmSave(findForm(this), ${timereport.id}, new Date()); return false" title="Verlängern" style="border: 0; background-color: transparent"><i class="bi bi-skip-end"></i></button>
<button type="button" onclick="confirmSave(findForm(this), ${timereport.id}); return false" title="Speichern" style="border: 0; background-color: transparent"><i class="bi bi-floppy"></i></button>
<button type="button" onclick="createFavorite(findForm(this), ${timereport.id}); return false"
Expand Down

0 comments on commit f58075d

Please sign in to comment.