better admin calendar

This commit is contained in:
Priec
2026-05-16 19:17:12 +02:00
parent 8e99e53d8a
commit b5d1fd46ed
2 changed files with 39 additions and 9 deletions

View File

@@ -145,7 +145,7 @@ fn flush_free_run(run: &mut Vec<Row>, out: &mut Vec<Row>) {
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);