From 563784d5fbeb36572b1da1df46462d866acf2eef Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 30 Apr 2026 18:08:06 +0200 Subject: [PATCH] fix: show Close week button without requiring all workdays closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The frontend was blocking week close until every workday had a closed_days record, which no longer matches the backend's rules (untracked days are implicitly 0h). Replace the all-workdays-closed guard with a simple check: week has started (Monday ≤ today) and is not already closed. The server returns a clear error if a day with entries still needs closing. Also fixes a pre-existing TS type narrowing error on currentSettings and removes the now-unused .hint CSS rule. --- web/src/routes/week/+page.svelte | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/web/src/routes/week/+page.svelte b/web/src/routes/week/+page.svelte index d75c031..95b839d 100644 --- a/web/src/routes/week/+page.svelte +++ b/web/src/routes/week/+page.svelte @@ -9,7 +9,7 @@ let dayKeys = $derived(weekDayKeys(weekKey)); let closedDaysMap: Record = $state({}); let closedWeek: ClosedWeek | null = $state(null); - let currentSettings: Settings | null = $state(null); + let currentSettings = $state(null); let error = $state(''); async function load() { @@ -61,10 +61,10 @@ currentSettings ? currentSettings.hours_per_week * 3_600_000 : 0 ); - const allWorkdaysClosed = $derived( - currentSettings - ? dayKeys.every((dk) => !isWorkday(dk, currentSettings!.workdays_mask) || !!closedDaysMap[dk]) - : false + // Week can be closed if it's not already closed and the week has started + // (i.e. Monday ≤ today). The server enforces the detailed per-day rules. + const canCloseWeek = $derived( + !closedWeek && dayKeys[0] <= todayKey() ); function prevWeek() { weekKey = offsetWeek(weekKey, -1); } @@ -132,10 +132,8 @@

Week closed — overtime: {formatDelta(closedWeek.delta_ms)}

- {:else if allWorkdaysClosed} + {:else if canCloseWeek} - {:else} -

Close all workdays to close the week.

{/if} @@ -167,5 +165,4 @@ .btn.close-week { background: #343a40; color: #fff; border: none; padding: 0.55rem 1.4rem; border-radius: 6px; font-size: 1rem; font-weight: 600; } .week-closed { background: #d4edda; border-radius: 8px; padding: 0.75rem 1rem; display: flex; align-items: center; justify-content: space-between; } .week-closed button { background: none; border: 1px solid #155724; color: #155724; border-radius: 6px; padding: 0.3rem 0.6rem; font-size: 0.875rem; } - .hint { color: #6c757d; font-size: 0.875rem; font-style: italic; }