mobile resolution
This commit is contained in:
@@ -89,6 +89,9 @@ pub struct CalendarPage {
|
||||
/// `false` on the public calendar once it reaches the two-week look-back
|
||||
/// limit, which disables the "previous week" button. Always `true` for admin.
|
||||
pub can_prev: bool,
|
||||
/// Index (0–6, Mon–Sun) of the day shown first in the mobile single-day
|
||||
/// view — today when the displayed week contains it, otherwise Monday.
|
||||
pub mobile_day: i64,
|
||||
pub days: Vec<DayHead>,
|
||||
pub rows: Vec<Row>,
|
||||
}
|
||||
@@ -193,6 +196,9 @@ 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();
|
||||
let mobile_day = if (0..7).contains(&day_offset) { day_offset } else { 0 };
|
||||
let sunday = monday + Duration::days(6);
|
||||
|
||||
let days: Vec<DayHead> = (0..7i64)
|
||||
@@ -278,6 +284,7 @@ pub async fn build_calendar(
|
||||
.to_string(),
|
||||
next_week: (monday + Duration::days(7)).format("%Y-%m-%d").to_string(),
|
||||
can_prev,
|
||||
mobile_day,
|
||||
days,
|
||||
rows,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user