From b5d1fd46ed61697ad3b18074ef79fa36ab22d8e3 Mon Sep 17 00:00:00 2001 From: Priec Date: Sat, 16 May 2026 19:17:12 +0200 Subject: [PATCH] better admin calendar --- ht_booking/assets/views/calendar/week.html | 37 ++++++++++++++++++---- ht_booking/src/controllers/calendar.rs | 11 +++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/ht_booking/assets/views/calendar/week.html b/ht_booking/assets/views/calendar/week.html index 1e8b45a..9d3b19b 100644 --- a/ht_booking/assets/views/calendar/week.html +++ b/ht_booking/assets/views/calendar/week.html @@ -33,11 +33,26 @@ #cal .cal-day-2 { display: table-cell; } #cal.cal-js .cal-day { display: none; } #cal.cal-js .cal-day.cal-day-on { display: table-cell; } + /* Slim the hour column to its compact label so bookings get the width. */ + #cal tbody td:first-child { + width: 1%; + white-space: nowrap; + padding: 0.3rem 0.4rem; + font-size: 0.7rem; + line-height: 1.15; + } } {% if is_admin %} {% endif %} {% endblock head %} @@ -185,7 +210,7 @@ {%- if cell.title %}{{ cell.title }}{% endif -%} {%- if cell.contact %}{{ cell.contact }}{% endif -%} - {%- if cell.note %}{{ cell.note }}{% endif -%} + {%- if cell.note %}{{ cell.note }}{% endif -%} {% endif %} diff --git a/ht_booking/src/controllers/calendar.rs b/ht_booking/src/controllers/calendar.rs index 04b188d..4b4fde1 100644 --- a/ht_booking/src/controllers/calendar.rs +++ b/ht_booking/src/controllers/calendar.rs @@ -145,7 +145,7 @@ fn flush_free_run(run: &mut Vec, out: &mut Vec) { let first = run.first().map_or(FIRST_HOUR, hour_of); let last = run.last().map_or(first, hour_of); let hour_label = if run.len() > 1 { - format!("{first:02}:00 – {:02}:00", last + 1) + format!("{first:02}:00–{:02}:00", last + 1) } else { format!("{first:02}:00") }; @@ -196,8 +196,13 @@ pub async fn build_calendar( let min_monday = monday_of(Utc::now().date_naive()) - Duration::weeks(2); let monday = if is_admin { monday } else { monday.max(min_monday) }; let can_prev = is_admin || monday > min_monday; - // Mobile single-day view opens on today when it falls in the shown week. - let day_offset = (Utc::now().date_naive() - monday).num_days(); + // The mobile day-window opens on the requested day when a week was given + // (so returning from the booking editor lands back on it), else on today. + let pivot = q_week + .as_deref() + .and_then(|w| NaiveDate::parse_from_str(w, "%Y-%m-%d").ok()) + .unwrap_or_else(|| Utc::now().date_naive()); + let day_offset = (pivot - monday).num_days(); let mobile_day = if (0..7).contains(&day_offset) { day_offset } else { 0 }; let sunday = monday + Duration::days(6);