Add a time-of-day race day schedule to Event Manager

Events can now be given a start time and a gap between sessions on a
new "Schedule" panel; every session's planned clock time cascades
automatically in running order (practice, qualifying, finals), and
once a session actually starts or finishes, everything after it
re-anchors to that real time - a late start or a session that ran
long (including any pause) pushes the rest of the day forward with
no manual reschedule step. The scheduled time now also shows on the
printed/PDF start lists.

Printable start lists and manually moving a driver to start last in
their own heat (for a mechanic-time request) already existed, so
this only builds the missing piece: the schedule itself.

Also fixes a real pre-existing bug in the same session-ordering logic
this feature relies on: getSessionSortWeight used `order[type] || 99`,
which silently treated open_practice's own weight of 0 as falsy and
sorted practice sessions dead last instead of first in print/PDF
output.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Sonnet 5 committed 2026-09-10 22:33:57 +02:00
1 parent a449bec07d
commit cf89086dff
11 files changed
+250 -8

No files matched your search

+27
View File
@@ -86,6 +86,7 @@ export function renderEventManagerView(context) {
ensureSessionDriverOrder,
reorderList,
getEventName,
buildEventSchedule,
} = context;
const selectedTeamEditId = getSelectedTeamEditId();
@@ -147,12 +148,14 @@ export function renderEventManagerView(context) {
if (!selectedGridSessionId && selectedGridSession) {
setSelectedGridSessionId(selectedGridSession.id);
}
const eventSchedule = event.mode === "race" ? buildEventSchedule(event) : [];
eventManageArea.innerHTML = renderEventManagerMarkup({
event,
t,
escapeHtml,
sessions,
eventSchedule,
sessionTypeChoices,
sessionTypeHintKey,
raceTeams,
@@ -692,6 +695,30 @@ export function renderEventManagerView(context) {
refreshManager();
});
document.getElementById("scheduleForm")?.addEventListener("submit", (e) => {
e.preventDefault();
const form = new FormData(e.currentTarget);
const startValue = String(form.get("scheduleStartAt") || "").trim();
const parsedStart = startValue ? new Date(startValue).getTime() : NaN;
const gapMin = Math.max(0, Number(form.get("scheduleGapMin")) || 0);
updateEvent((item) => ({
...item,
raceConfig: {
...item.raceConfig,
scheduleStartAt: Number.isFinite(parsedStart) ? parsedStart : null,
scheduleGapMin: gapMin,
},
}));
saveState();
refreshManager();
});
document.getElementById("scheduleClear")?.addEventListener("click", () => {
updateEvent((item) => ({ ...item, raceConfig: { ...item.raceConfig, scheduleStartAt: null } }));
saveState();
refreshManager();
});
document.getElementById("applyRacePreset")?.addEventListener("click", () => {
const formElement = document.getElementById("raceFormatForm");
if (!(formElement instanceof HTMLFormElement)) {