Kalender: Verschieben erst nach Bestätigung mit Anzeige des neuen Zeitraums
This commit is contained in:
parent
c04a09ddf6
commit
75e274cc71
6 changed files with 93 additions and 5 deletions
|
|
@ -92,7 +92,7 @@ function url(string $path = '/'): string
|
|||
}
|
||||
|
||||
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
|
||||
const DIC_ASSET_VERSION = '18';
|
||||
const DIC_ASSET_VERSION = '19';
|
||||
|
||||
function asset(string $path): string
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ $minWidth = match ($view) {
|
|||
<a class="cal-label__add" href="<?= e(url('/bookings/new?trailer=' . (int) $trailer['id'] . '&start=' . $date)) ?>" aria-label="Neue Buchung für <?= e($trailer['label']) ?>">+</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="cal-track" style="--row-h: <?= (int) $row['height'] ?>px; --lanes: <?= (int) $row['lanes'] ?>" data-trailer-id="<?= (int) $trailer['id'] ?>">
|
||||
<div class="cal-track" style="--row-h: <?= (int) $row['height'] ?>px; --lanes: <?= (int) $row['lanes'] ?>" data-trailer-id="<?= (int) $trailer['id'] ?>" data-trailer-label="<?= e($trailer['label']) ?>">
|
||||
<div class="cal-cells">
|
||||
<?php foreach ($days as $day): ?>
|
||||
<?php if ($canCreate): ?>
|
||||
|
|
@ -154,6 +154,7 @@ $minWidth = match ($view) {
|
|||
data-booking-id="<?= (int) $booking['id'] ?>"
|
||||
data-trailer-id="<?= (int) $booking['trailer_id'] ?>"
|
||||
data-start-date="<?= e($booking['start_date']) ?>"
|
||||
data-customer-name="<?= e($booking['customer_name']) ?>"
|
||||
data-days="<?= days_between($booking['start_date'], $booking['end_date']) + 1 ?>"
|
||||
style="--left: <?= number_format($geo['left'], 5, '.', '') ?>%; --width: <?= number_format($geo['width'], 5, '.', '') ?>%; --top: <?= number_format($geo['top'], 5, '.', '') ?>%; --height: <?= number_format($geo['height'], 5, '.', '') ?>%; --bar: <?= e($booking['trailer_color']) ?>; --bar-text: <?= e(contrast_color($booking['trailer_color'])) ?>;"
|
||||
aria-label="<?= e($aria) ?>"
|
||||
|
|
|
|||
|
|
@ -162,6 +162,23 @@ $navActive = static function (string $area) use ($path): string {
|
|||
<div class="booking-dialog__inner" id="booking-dialog-content"></div>
|
||||
</dialog>
|
||||
|
||||
<dialog class="confirm-dialog" id="move-dialog" aria-labelledby="move-dialog-title">
|
||||
<form method="dialog" class="confirm-dialog__inner">
|
||||
<h2 id="move-dialog-title">Buchung verschieben?</h2>
|
||||
<p class="confirm-dialog__lead" data-move-customer></p>
|
||||
<dl class="confirm-dialog__facts">
|
||||
<div><dt>Bisher</dt><dd data-move-from></dd></div>
|
||||
<div><dt>Neu</dt><dd data-move-to></dd></div>
|
||||
<div><dt>Kühlanhänger</dt><dd data-move-trailer></dd></div>
|
||||
</dl>
|
||||
<p class="muted small">Erinnerungen werden an den neuen Zeitraum angepasst.</p>
|
||||
<div class="confirm-dialog__actions">
|
||||
<button class="btn" type="submit" value="cancel">Abbrechen</button>
|
||||
<button class="btn primary" type="submit" value="ok">OK, verschieben</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<div class="toast" id="toast" role="status" aria-live="polite" hidden></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -677,6 +677,21 @@ a .ico, button .ico { pointer-events: none; }
|
|||
}
|
||||
.booking-dialog::backdrop { background: rgba(6, 26, 46, .42); backdrop-filter: blur(3px); }
|
||||
.booking-dialog__inner { max-height: min(90vh, 900px); overflow-y: auto; }
|
||||
.confirm-dialog {
|
||||
width: min(460px, calc(100vw - 28px));
|
||||
padding: 0; border: 0; border-radius: var(--radius-xl);
|
||||
background: #fff; box-shadow: var(--shadow-lg); color: var(--ink-2);
|
||||
}
|
||||
.confirm-dialog::backdrop { background: rgba(6, 26, 46, .42); backdrop-filter: blur(3px); }
|
||||
.confirm-dialog__inner { padding: 20px 22px 16px; }
|
||||
.confirm-dialog__inner h2 { font-size: 1.15rem; margin-bottom: 4px; }
|
||||
.confirm-dialog__lead { font-size: .86rem; color: var(--muted); margin-bottom: 12px; }
|
||||
.confirm-dialog__facts { display: grid; gap: 8px; margin: 0 0 12px; }
|
||||
.confirm-dialog__facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: baseline; }
|
||||
.confirm-dialog__facts dt { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
|
||||
.confirm-dialog__facts dd { margin: 0; font-size: .88rem; color: var(--ink); }
|
||||
.confirm-dialog__facts dd strong { color: var(--brand-ink, var(--brand)); }
|
||||
.confirm-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
|
||||
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line-soft); background: linear-gradient(180deg, var(--ice-50), #fff); }
|
||||
.panel-head__main { min-width: 0; }
|
||||
.panel-head__trailer { display: flex; align-items: center; gap: 7px; font-size: .76rem; font-weight: 700; color: var(--muted); }
|
||||
|
|
@ -949,6 +964,7 @@ a .ico, button .ico { pointer-events: none; }
|
|||
.copy-list__row { grid-template-columns: 120px 1fr; }
|
||||
.panel-body { grid-template-columns: 1fr; }
|
||||
.booking-dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; }
|
||||
.confirm-dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; }
|
||||
.booking-dialog__inner { max-height: 88vh; }
|
||||
.trailer-admin__head { display: none; }
|
||||
.trailer-admin__row { grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 0; }
|
||||
|
|
@ -1012,7 +1028,7 @@ a .ico, button .ico { pointer-events: none; }
|
|||
}
|
||||
@media print {
|
||||
.topbar, .footer, .flash-wrap, .page-head__actions, .cal-toolbar, .cal-foot,
|
||||
.panel-actions, .breadcrumb, .detail-side .card:last-child, .toast, .booking-dialog { display: none !important; }
|
||||
.panel-actions, .breadcrumb, .detail-side .card:last-child, .toast, .booking-dialog, .confirm-dialog { display: none !important; }
|
||||
body { background: #fff; }
|
||||
.page { padding: 0; max-width: none; }
|
||||
.card, .panel { box-shadow: none; border-color: #ccc; }
|
||||
|
|
|
|||
|
|
@ -547,6 +547,37 @@
|
|||
return date.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
const formatIso = (iso) => {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(String(iso || ''))) return '–';
|
||||
const [y, m, d] = iso.split('-');
|
||||
return `${d}.${m}.${y}`;
|
||||
};
|
||||
const formatIsoRange = (from, to) => (from === to
|
||||
? formatIso(from)
|
||||
: `${formatIso(from)} – ${formatIso(to)}`);
|
||||
|
||||
// Bestätigung vor dem Verschieben: zeigt den neuen Zeitraum und wartet auf OK.
|
||||
const moveDialog = document.querySelector('#move-dialog');
|
||||
const askMove = (payload) => new Promise((resolve) => {
|
||||
const question = `Buchung „${payload.customer}“ auf ${formatIsoRange(payload.newStart, payload.newEnd)} verschieben?`;
|
||||
if (!moveDialog || typeof moveDialog.showModal !== 'function') {
|
||||
resolve(window.confirm(question));
|
||||
return;
|
||||
}
|
||||
const setText = (selector, value) => {
|
||||
const node = moveDialog.querySelector(selector);
|
||||
if (node) node.textContent = value;
|
||||
};
|
||||
setText('[data-move-customer]', payload.customer);
|
||||
setText('[data-move-from]', formatIsoRange(payload.startDate, payload.startEnd));
|
||||
setText('[data-move-to]', formatIsoRange(payload.newStart, payload.newEnd));
|
||||
setText('[data-move-trailer]', payload.trailerLabel
|
||||
+ (payload.trailerChanged ? ` (bisher ${payload.previousTrailerLabel})` : ''));
|
||||
moveDialog.returnValue = '';
|
||||
moveDialog.addEventListener('close', () => resolve(moveDialog.returnValue === 'ok'), { once: true });
|
||||
moveDialog.showModal();
|
||||
});
|
||||
|
||||
const resetDrag = () => {
|
||||
if (!drag) return;
|
||||
drag.bar.style.transform = '';
|
||||
|
|
@ -610,8 +641,12 @@
|
|||
const dx = event.clientX - active.startX;
|
||||
const shift = Math.round(dx / active.dayWidth);
|
||||
const startDate = active.bar.dataset.startDate;
|
||||
const customerName = active.bar.dataset.customerName || 'Buchung';
|
||||
const spanDays = Math.max(1, Number(active.bar.dataset.days || 1));
|
||||
const originalTrailer = active.bar.dataset.trailerId;
|
||||
const originalTrailerLabel = active.bar.closest('.cal-track')?.dataset.trailerLabel || '';
|
||||
const targetTrailer = active.target?.dataset.trailerId || originalTrailer;
|
||||
const targetTrailerLabel = active.target?.dataset.trailerLabel || originalTrailerLabel;
|
||||
const bookingId = active.bar.dataset.bookingId;
|
||||
|
||||
resetDrag();
|
||||
|
|
@ -620,9 +655,28 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const startEnd = addDays(startDate, spanDays - 1);
|
||||
const newStart = addDays(startDate, shift);
|
||||
const newEnd = addDays(newStart, spanDays - 1);
|
||||
|
||||
const confirmed = await askMove({
|
||||
customer: customerName,
|
||||
startDate,
|
||||
startEnd,
|
||||
newStart,
|
||||
newEnd,
|
||||
trailerLabel: targetTrailerLabel,
|
||||
trailerChanged: targetTrailer !== originalTrailer,
|
||||
previousTrailerLabel: originalTrailerLabel
|
||||
});
|
||||
if (!confirmed) {
|
||||
toast('Verschieben abgebrochen.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const body = new URLSearchParams({
|
||||
start_date: addDays(startDate, shift),
|
||||
start_date: newStart,
|
||||
trailer_id: targetTrailer,
|
||||
_csrf: csrf
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* zwischengespeichert, damit niemand veraltete Buchungen sieht.
|
||||
*/
|
||||
|
||||
const VERSION = 'dic-v10';
|
||||
const VERSION = 'dic-v11';
|
||||
const CACHE = VERSION;
|
||||
const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, '');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue