From a5f2f769c467bcdbaec00793e4ef14b2958112d1 Mon Sep 17 00:00:00 2001 From: Kristian Wind Date: Thu, 20 Aug 2026 07:30:55 +0200 Subject: [PATCH] fix(web): begivenhederne i en celle sorteres, hvor de tegnes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Serveren sorterer allerede, men en celle, der viser 14:00 over 09:15, ligner ikke en liste i forkert rækkefølge — den ligner et forkert klokkeslæt på chippen, og det er langt værre at skulle udelukke. Heldags først: en heldags begivenhed er et bånd hen over dagen, ikke noget der sker på et punkt i den. --- web/src/lib/components/CalendarView.svelte | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/web/src/lib/components/CalendarView.svelte b/web/src/lib/components/CalendarView.svelte index 56bbe20..b00a6f1 100644 --- a/web/src/lib/components/CalendarView.svelte +++ b/web/src/lib/components/CalendarView.svelte @@ -149,12 +149,25 @@ (!projectId || t.project_id === projectId) ); - // Which cells an event covers, rather than where it starts. A trip from Friday - // to Monday is in all four, and asking only about the start day would draw it - // once and leave three days looking clear. + /** + * Which cells an event covers, rather than where it starts. A trip from Friday + * to Monday is in all four, and asking only about the start day would draw it + * once and leave three days looking clear. + * + * Ordered here rather than trusted from the caller. The server does sort, but a + * cell that shows 14:00 above 09:15 does not look like a list in the wrong + * order — it looks like the clock on the chip is wrong, which is a far worse + * thing to have to rule out. All-day first, because an all-day event is a band + * over the whole day rather than something that happens at a point in it. + */ const eventsOn = (date) => { const day = iso(date); - return events.filter((e) => e.start_day <= day && e.end_day >= day); + return events + .filter((e) => e.start_day <= day && e.end_day >= day) + .toSorted((a, b) => { + if (a.all_day !== b.all_day) return a.all_day ? -1 : 1; + return (a.starts_at ?? '').localeCompare(b.starts_at ?? ''); + }); }; /**