Umstellung Auf h:mm in verwaltung
This commit is contained in:
@@ -99,13 +99,13 @@
|
||||
<div style="display: inline-flex; gap: 8px; align-items: center; margin-right: 20px;">
|
||||
<strong>Überstunden-Korrektur:</strong>
|
||||
<input
|
||||
type="number"
|
||||
step="0.25"
|
||||
type="text"
|
||||
class="overtime-offset-input"
|
||||
data-user-id="<%= employee.user.id %>"
|
||||
value="0"
|
||||
style="width: 90px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px;"
|
||||
title="Korrektur eingeben (z. B. +10 oder -20). Nach dem Speichern wird das Feld auf 0 gesetzt." />
|
||||
value="0:00"
|
||||
placeholder="z. B. 1:30, 10:30 oder -0:45"
|
||||
style="width: 110px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px;"
|
||||
title="Korrektur in h:mm (z. B. 1:30, 10:30 oder -0:45). Nach dem Speichern wird das Feld auf 0:00 gesetzt." />
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success btn-sm save-overtime-offset-btn"
|
||||
@@ -697,11 +697,16 @@
|
||||
|
||||
// leere Eingabe => 0 (Backend macht das auch, aber UI soll sauber sein)
|
||||
const raw = (input.value || '').trim();
|
||||
const value = raw === '' ? '' : Number(raw);
|
||||
const value = (typeof parseHoursMin === 'function' ? parseHoursMin(raw) : null);
|
||||
if (value === null && raw !== '') {
|
||||
alert('Ungültiges Format. Bitte h:mm oder hh:mm eingeben (z. B. 1:30, 10:30 oder -0:45).');
|
||||
return;
|
||||
}
|
||||
const decimalValue = (value === null ? 0 : value);
|
||||
|
||||
// Wenn keine Korrektur (0), nichts tun außer UI auf 0 zu normalisieren
|
||||
if (value === 0) {
|
||||
input.value = 0;
|
||||
// Wenn keine Korrektur (0), nichts tun außer UI auf 0:00 zu normalisieren
|
||||
if (decimalValue === 0) {
|
||||
input.value = (typeof decimalHoursToHhMm === 'function' ? decimalHoursToHhMm(0) : '0:00');
|
||||
this.textContent = originalText;
|
||||
this.disabled = false;
|
||||
return;
|
||||
@@ -713,7 +718,7 @@
|
||||
// Modal: Grund ist Pflicht
|
||||
showOvertimeCorrectionReasonModal({
|
||||
title: 'Grund für die Überstunden-Korrektur',
|
||||
prompt: `Korrektur: ${value >= 0 ? '+' : ''}${formatHoursMin(value)}`,
|
||||
prompt: `Korrektur: ${decimalValue >= 0 ? '+' : ''}${formatHoursMin(decimalValue)}`,
|
||||
onCancel: () => {
|
||||
delete this.dataset.modalOpen;
|
||||
this.disabled = false;
|
||||
@@ -724,7 +729,7 @@
|
||||
const resp = await fetch(`/api/verwaltung/user/${userId}/overtime-offset`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ overtime_offset_hours: value, reason })
|
||||
body: JSON.stringify({ overtime_offset_hours: decimalValue, reason })
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (!resp.ok) {
|
||||
@@ -735,10 +740,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalisiere Input auf Zahl (Backend gibt number zurück)
|
||||
input.value = (data.overtime_offset_hours !== undefined && data.overtime_offset_hours !== null)
|
||||
? Number(data.overtime_offset_hours)
|
||||
: 0;
|
||||
// Normalisiere Input auf h:mm (Backend gibt 0 zurück nach Speichern)
|
||||
input.value = (typeof decimalHoursToHhMm === 'function')
|
||||
? decimalHoursToHhMm((data.overtime_offset_hours !== undefined && data.overtime_offset_hours !== null) ? Number(data.overtime_offset_hours) : 0)
|
||||
: '0:00';
|
||||
|
||||
// Stats für diesen User neu laden
|
||||
const statDivs = document.querySelectorAll(`.group-stats[data-user-id="${userId}"]`);
|
||||
|
||||
Reference in New Issue
Block a user