Smartphone-Kalender: Monatsansicht rendert ebenfalls +/- 2 Monate zum Wischen

This commit is contained in:
torsten 2026-11-25 22:41:55 +01:00
parent 2ca19dd2fb
commit 9d2154ee2d
3 changed files with 16 additions and 10 deletions

View file

@ -418,19 +418,24 @@ function page_calendar(array $user): void
$employeeId = query_int('employee');
$showCancelled = query_string('cancelled') === '1';
// Startwoche: Montag der Woche, in der $date liegt.
$focusFrom = week_start($date);
$focusTo = add_days($focusFrom, CALENDAR_WEEKS * 7 - 1);
if ($view === 'day') {
$focusFrom = $date;
$from = $to = $date;
} elseif ($view === 'month') {
$from = month_start($date);
$focusFrom = month_start($date);
$from = $focusFrom;
$to = month_end($date);
if (client_is_mobile()) {
// Smartphone: auch im Monat ± 2 Monate rendern, damit sich der
// Kalender seitlich durchwischen lässt.
$from = date_obj($focusFrom)->modify('-' . CALENDAR_MOBILE_MONTHS . ' months')->format('Y-m-d');
$to = date_obj($focusFrom)->modify('+' . (CALENDAR_MOBILE_MONTHS + 1) . ' months')->modify('-1 day')->format('Y-m-d');
}
} else {
// Vier Kalenderwochen ab dem Montag der Woche, in der $date liegt.
$focusFrom = week_start($date);
$from = $focusFrom;
$to = $focusTo;
$to = add_days($focusFrom, CALENDAR_WEEKS * 7 - 1);
if (client_is_mobile()) {
// Smartphone: mehr Wochen rendern, damit sich der Kalender nach
// links und rechts wischen lässt (± 2 Monate um die Startwoche).
@ -505,8 +510,9 @@ function page_calendar(array $user): void
if ($view === 'day') {
$title = fmt_date_long($date);
} elseif ($view === 'weeks') {
$title = 'KW ' . date_obj($focusFrom)->format('W') . '–' . date_obj($focusTo)->format('W')
. ' · ' . fmt_date_range($focusFrom, $focusTo);
$title = 'KW ' . date_obj($focusFrom)->format('W') . '–'
. date_obj(add_days($focusFrom, CALENDAR_WEEKS * 7 - 1))->format('W')
. ' · ' . fmt_date_range($focusFrom, add_days($focusFrom, CALENDAR_WEEKS * 7 - 1));
} else {
$title = fmt_month($date);
}

View file

@ -92,7 +92,7 @@ function url(string $path = '/'): string
}
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
const DIC_ASSET_VERSION = '22';
const DIC_ASSET_VERSION = '23';
function asset(string $path): string
{

View file

@ -6,7 +6,7 @@
* zwischengespeichert, damit niemand veraltete Buchungen sieht.
*/
const VERSION = 'dic-v14';
const VERSION = 'dic-v15';
const CACHE = VERSION;
const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, '');