feat(layouts): switch track layout mid-practice and view stats per layout

A club can run one Open Practice all season and re-lay the track now and then.
Previously a session's layout was frozen at start and every training lap inherited
it, so a season-long practice stayed on its first layout forever, and changing layout
was hidden under Settings -> Appearance.

- Each practice lap now counts toward the layout active when it was driven; a running
  practice session moves onto a new layout when one is added
- "New layout" strip on Training stats, Race Day and the Dashboard, offered only around
  practice; a running race session blocks layout changes everywhere
- "Stats for" selector (current / older layout / before layouts / all layouts) on
  Training stats and in the driver's mobile profile (?layout= on the public API)
- A layout that has practice laps on it can no longer be deleted
- Fix: the buildDriverTrainingStats wrapper in app.js dropped extra arguments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-09-27 21:24:44 +02:00
1 parent 196437d25b
commit 627179b95a
22 files changed
+454 -44

No files matched your search

+5 -1
View File
@@ -1,3 +1,5 @@
import { isPracticeSessionType } from "./track_layouts_logic.js";
import { renderTrackLayoutBar, bindTrackLayoutBar } from "./track_layout_bar.js";
export function getRaceDayCheckAction(item, session) {
if (item.level === "ok") return null;
if (["backend", "decoder", "split_decoder", "pit_decoders", "audio"].includes(item.id)) {
@@ -56,7 +58,7 @@ export function renderRaceDayView(deps) {
getEventName, getSessionTypeLabel, getStatusLabel, getStartModeLabel,
getSessionTiming, getSessionGridEntries, buildRaceDayQueue, buildRaceDayPreflight,
backendAvailable, selectSession, startSession, finishSession, pauseSession, resumeSession,
saveLapWindow, navigateTo, getStartLightState,
saveLapWindow, navigateTo, getStartLightState, addTrackLayout, renderView,
} = deps;
const queue = buildRaceDayQueue(state);
const session = queue.current;
@@ -79,6 +81,7 @@ export function renderRaceDayView(deps) {
<span class="race-day-kicker">${t("race_day.current")}</span>
<h2>${session ? escapeHtml(session.name) : t("race_day.no_session")}</h2>
<p>${session ? `${escapeHtml(getEventName(session.eventId))} · ${escapeHtml(getSessionTypeLabel(session.type))} · ${escapeHtml(getStartModeLabel(session.startMode))}` : t("race_day.no_session_hint")}</p>
${renderTrackLayoutBar({ state, t, escapeHtml, showNewButton: !session || isPracticeSessionType(session.type) })}
</div>
<div class="race-day-clock"><strong data-race-day-clock>${clock}</strong><span>${session ? escapeHtml(getStatusLabel(session.status)) : t("race_day.none")}</span></div>
</section>
@@ -181,6 +184,7 @@ export function renderRaceDayView(deps) {
}
saveLapWindow(session, minLapSec, maxLapSec);
});
bindTrackLayoutBar(dom.view, { state, t, addTrackLayout, renderView });
document.getElementById("raceDayStart")?.addEventListener("click", async () => {
if (!session || !preflight.ready) return;
if (!isSelected) selectSession(session.id, { render: false });