Raids: use a real date/time picker instead of a free-text field
The "Datum & Uhrzeit" input in raid create/edit is now <input type="datetime-local">, styled to match the dark theme. The backend still expects "TT.MM.JJJJ HH:MM" (the Discord bot parses it verbatim), so raids.js converts the picker's value to that format via a plain string reshuffle (no Date object, so no timezone drift) before posting it as date_raw. The edit form prefills the picker from the raid's existing timestamp. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
3b7ee9bb8a
commit
c8a1748ae5
3 changed files with 25 additions and 4 deletions
|
|
@ -359,6 +359,7 @@ label { font-weight: 600; font-size: 0.9rem; }
|
|||
input[type="text"],
|
||||
input[type="email"],
|
||||
input[type="password"],
|
||||
input[type="datetime-local"],
|
||||
textarea,
|
||||
select {
|
||||
background: var(--bg-panel-alt);
|
||||
|
|
@ -375,6 +376,13 @@ input:focus, select:focus, textarea:focus {
|
|||
border-color: var(--gold);
|
||||
}
|
||||
|
||||
/* Chrome/Edge faerben das Kalender-/Uhr-Icon standardmaessig schwarz, das im
|
||||
dunklen Theme unsichtbar waere. */
|
||||
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
|
||||
filter: invert(1);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,17 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Wandelt den Wert eines <input type="datetime-local"> ("YYYY-MM-DDTHH:MM") in das vom
|
||||
// Bot erwartete Format "TT.MM.JJJJ HH:MM" um - reine Stringumformung ohne Date-Objekt,
|
||||
// damit keine Zeitzonenverschiebung passieren kann.
|
||||
function formatDateRaw(localValue) {
|
||||
var parts = (localValue || '').split('T');
|
||||
if (parts.length !== 2) return '';
|
||||
var dateParts = parts[0].split('-');
|
||||
if (dateParts.length !== 3) return '';
|
||||
return dateParts[2] + '.' + dateParts[1] + '.' + dateParts[0] + ' ' + parts[1];
|
||||
}
|
||||
|
||||
// ---- Anmelde-Popup ----
|
||||
var modal = document.getElementById('raid-signup-modal');
|
||||
var groupPicker = document.getElementById('raid-signup-group-picker');
|
||||
|
|
@ -174,7 +185,7 @@
|
|||
postJson('/raid_edit_action.php', {
|
||||
raid_id: form.getAttribute('data-raid-id'),
|
||||
title: form.title.value,
|
||||
date_raw: form.date_raw.value,
|
||||
date_raw: formatDateRaw(form.date_local.value),
|
||||
requirements: form.requirements.value,
|
||||
gearscore: form.gearscore.value,
|
||||
group_names: groupNames.join(', '),
|
||||
|
|
@ -261,7 +272,7 @@
|
|||
feedback.className = 'raid-create-feedback text-muted';
|
||||
postJson('/raid_create_action.php', {
|
||||
title: raidCreateForm.title.value,
|
||||
date_raw: raidCreateForm.date_raw.value,
|
||||
date_raw: formatDateRaw(raidCreateForm.date_local.value),
|
||||
requirements: raidCreateForm.requirements.value,
|
||||
gearscore: raidCreateForm.gearscore.value,
|
||||
group_names: groupNames.join(', '),
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<div>
|
||||
<label>Datum & Uhrzeit</label>
|
||||
<input type="text" name="date_raw" placeholder="TT.MM.JJJJ HH:MM" required>
|
||||
<input type="datetime-local" name="date_local" required>
|
||||
</div>
|
||||
<div>
|
||||
<label>Max. Spieler</label>
|
||||
|
|
@ -150,8 +150,10 @@ include __DIR__ . '/includes/header.php';
|
|||
$title = (string) ($raid['title'] ?? 'Raid');
|
||||
$dateRaw = (string) ($raid['date'] ?? '');
|
||||
$dateLabel = $dateRaw;
|
||||
$dateLocal = '';
|
||||
if (!empty($raid['timestamp'])) {
|
||||
$dateLabel = date('d.m.Y H:i', (int) $raid['timestamp']) . ' Uhr';
|
||||
$dateLocal = date('Y-m-d\TH:i', (int) $raid['timestamp']);
|
||||
}
|
||||
$requirements = trim((string) ($raid['requirements'] ?? ''));
|
||||
$gearscore = trim((string) ($raid['gearscore'] ?? ''));
|
||||
|
|
@ -257,7 +259,7 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<div>
|
||||
<label>Datum & Uhrzeit</label>
|
||||
<input type="text" name="date_raw" value="<?= e($dateRaw) ?>" placeholder="TT.MM.JJJJ HH:MM">
|
||||
<input type="datetime-local" name="date_local" value="<?= e($dateLocal) ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label>Max. Spieler</label>
|
||||
|
|
|
|||
Loading…
Reference in a new issue