feat(race-setup): group a race's sessions per step, fold run steps, rare actions in a menu (1.53.0)

This commit is contained in:
larssand committed 2026-11-02 08:26:00 +01:00
1 parent b23410c190
commit 73e3d1ff75
12 files changed
+147 -25

No files matched your search

+6
View File
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.53.0 - 2026-11-02
### Changed
- Race Setup → Manage groups a race's sessions per step (practice, each qualifying round, finals). A step whose heats are all run is folded to one line and opens with a click; the step running now is marked. Printing, export, the grid and delete moved into a ⋯ menu on each session, so each row shows only ▲▼, Edit and Set active.
## 1.52.0 - 2026-11-02
### Changed
+2
View File
@@ -150,6 +150,8 @@ Lap validation:
The **race list** is grouped so it stays short: **Today** (and anything running), **Upcoming**, and **Done** folded away (races whose heats are all run or whose date has passed). Races on the same date are listed together, each with how far it has come (● running heat, *Next: Q2 H1*, *3/9 run* or ✓ Done). A search box finds older races.
In **Manage**, the sessions are grouped per step: practice / seeding, each qualifying round, finals. A step whose heats are all run is folded to one line (✓ Qualifying round 1 · 3/3 run) and opens with a click. Each session shows ▲▼, Edit and Set active; printing, export, the grid and delete are under **⋯**.
After creation the race is managed in four tabs (Race Setup → Manage):
- **Participants & teams:** tick who races, and manage teams for endurance.
- **Format:**
+2
View File
@@ -163,6 +163,8 @@ Varvkontroll:
**Racelistan** är grupperad så att den hålls kort: **Idag** (och det som pågår), **Kommande**, och **Körda** ihopfällt (race där alla heat är körda eller datumet har passerat). Race samma datum ligger ihop, var och ett med hur långt det kommit (● pågående heat, *Nästa: Q2 H1*, *3/9 körda* eller ✓ Klar). En sökruta hittar äldre race.
I **Hantera** är sessionerna grupperade per steg: träning / seedning, varje kvalomgång, finaler. Ett steg där alla heat är körda fälls ihop till en rad (✓ Kval omgång 1 · 3/3 körda) och öppnas med ett klick. Varje session visar ▲▼, Ändra och Sätt aktiv; utskrift, export, grid och ta bort finns under **⋯**.
Efter det hanteras racet i fyra flikar (Race Setup → Hantera):
- **Deltagare & lag:** bocka i vilka som kör, och hantera lag för endurance.
- **Format:**
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.52.0",
"version": "1.53.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.52.0",
"version": "1.53.0",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.52.0",
"version": "1.53.0",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+12
View File
@@ -2226,6 +2226,12 @@ const TRANSLATIONS = {
"events.session_max_cars_hint": "Sätt gräns om just den sessionen bara ska ha ett visst antal bilar.",
"events.edit_session_help": "Ändra sessionens namn, typ, tid och seed-/startinställningar här.",
"events.set_active": "Sätt aktiv",
"events.more_actions": "Fler val: utskrift, export, grid, ta bort",
"events.step_practice": "Träning / seedning",
"events.step_qual_round": "Kval omgång {round}",
"events.step_qual": "Kval",
"events.step_finals": "Finaler",
"events.step_count": "{done}/{total} körda",
"events.assignments": "Tilldelningar",
"events.na": "ej relevant",
"events.sponsor_tools": "Sponsorverktyg",
@@ -4174,6 +4180,12 @@ const TRANSLATIONS = {
"events.session_max_cars_hint": "Set a limit if this session should only allow a certain number of cars.",
"events.edit_session_help": "Edit the session name, type, timing and seed/start settings here.",
"events.set_active": "Set Active",
"events.more_actions": "More: print, export, grid, delete",
"events.step_practice": "Practice / seeding",
"events.step_qual_round": "Qualifying round {round}",
"events.step_qual": "Qualifying",
"events.step_finals": "Finals",
"events.step_count": "{done}/{total} run",
"events.assignments": "Assignments",
"events.na": "n/a",
"events.sponsor_tools": "Sponsor Event Tools",
+4
View File
@@ -1,4 +1,5 @@
import { orderSessionsForRunning, moveSessionInRunningOrder } from "./event_race_logic.js";
import { setSessionGroupOpen } from "./event_manager_view.js";
let activeManageTab = "setup";
// Maps a data-target anchor id (used by the step-card overview and the race-summary
// warning links) to the tab it now lives inside, so jumping to it also switches tabs
@@ -215,6 +216,9 @@ export function renderEventManagerView(context) {
getModeLabel,
renderTable,
});
eventManageArea.querySelectorAll("details[data-session-group]").forEach((group) => {
group.addEventListener("toggle", () => setSessionGroupOpen(event.id, group.dataset.sessionGroup, group.open));
});
const manageTabButtons = Array.from(eventManageArea.querySelectorAll(".manage-tab"));
const manageTabPanels = Array.from(eventManageArea.querySelectorAll("[data-manage-panel]"));
+57 -22
View File
@@ -1,4 +1,19 @@
import { PROLOGUE_OPTIONS_SEC, formatPrologueOption } from "./prologue_logic.js";
import { groupSessionsBySteps } from "./race_list_logic.js";
// Done steps are folded; one the operator opened stays open across re-renders (this page only).
const openSessionGroups = new Set();
export const isSessionGroupOpen = (eventId, stepId) => openSessionGroups.has(`${eventId}:${stepId}`);
// A ⋯ menu closes when anything outside it is clicked.
if (typeof document !== "undefined") {
document.addEventListener("click", (event) => {
document.querySelectorAll("details.row-menu[open]").forEach((menu) => { if (!menu.contains(event.target)) menu.open = false; });
});
}
export function setSessionGroupOpen(eventId, stepId, open) {
if (open) openSessionGroups.add(`${eventId}:${stepId}`);
else openSessionGroups.delete(`${eventId}:${stepId}`);
}
function formatDateTimeLocalValue(ms) {
const date = new Date(ms);
date.setSeconds(0, 0);
@@ -163,10 +178,23 @@ export function renderEventManagerMarkup(context) {
<p class="hint">${t("events.free_practice_note")}</p>
<p class="hint">${t("events.open_practice_note")}</p>
<div class="mt-16">
${renderTable(
[t("table.session"), t("table.type"), t("table.duration"), t("table.start_mode"), t("table.seeding"), t("table.status"), t(event.mode === "track" ? "events.assignments" : "events.participants"), t("events.actions")],
sessions.map((s, sessionIndex) => {
<div class="mt-16 session-groups">
${groupSessionsBySteps(sessions).map((group) => {
const title = group.step.id === "practice" ? t("events.step_practice")
: group.step.round ? t("events.step_qual_round", { round: group.step.round })
: group.step.id === "qual" ? t("events.step_qual")
: group.step.id === "final" ? t("events.step_finals")
: getSessionTypeLabel(group.step.type);
const open = group.state !== "done" || isSessionGroupOpen(event.id, group.step.id);
return `
<details class="session-group is-${group.state}" data-session-group="${escapeHtml(group.step.id)}" ${open ? "open" : ""}>
<summary>
<strong>${group.state === "done" ? "✓ " : group.state === "live" ? '<span class="live-dot" aria-hidden="true"></span> ' : ""}${escapeHtml(title)}</strong>
<small>${escapeHtml(t("events.step_count", { done: group.done, total: group.items.length }))}</small>
</summary>
${renderTable(
[t("table.session"), t("table.type"), t("table.duration"), t("table.start_mode"), t("table.seeding"), t("table.status"), t(event.mode === "track" ? "events.assignments" : "events.participants"), t("events.actions")],
group.items.map(({ session: s, index: sessionIndex }) => {
const assignCount =
event.mode === "track"
? (s.assignments || []).length
@@ -182,31 +210,38 @@ export function renderEventManagerMarkup(context) {
<td>${s.seedBestLapCount > 0 ? `${s.seedBestLapCount}` : "-"}</td>
<td>${escapeHtml(getStatusLabel(s.status))}</td>
<td>${assignCount || (event.mode === "track" ? t("events.na") : "-")}</td>
<td class="actions-inline">
<td class="actions-inline session-row-actions">
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="-1" title="${escapeHtml(t("events.move_session_up"))}" ${sessionIndex ? "" : "disabled"}>▲</button>
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="1" title="${escapeHtml(t("events.move_session_down"))}" ${sessionIndex < sessions.length - 1 ? "" : "disabled"}>▼</button>
<button id="session-edit-${s.id}" class="btn">${t("events.edit_session")}</button>
<button id="session-active-${s.id}" class="btn">${t("events.set_active")}</button>
${
event.mode === "race" && normalizeStartMode(s.startMode) === "position"
? `<button id="session-grid-${s.id}" class="btn" type="button">${t("events.open_grid")}</button>`
: ""
}
${
event.mode === "race" && ["qualification", "final"].includes(s.type)
? `
<button id="session-sheet-print-${s.id}" class="btn" type="button">${t("events.print_heat_sheet")}</button>
<button id="session-sheet-export-${s.id}" class="btn" type="button">${t("events.export_heat_sheet")}</button>
<button id="session-sheet-pdf-${s.id}" class="btn" type="button">${t("events.pdf_heat_sheet")}</button>
`
: ""
}
<button id="session-delete-${s.id}" class="btn btn-danger">${t("common.delete")}</button>
<details class="row-menu">
<summary class="btn btn-mini" title="${escapeHtml(t("events.more_actions"))}">⋯</summary>
<div class="row-menu-list">
${
event.mode === "race" && normalizeStartMode(s.startMode) === "position"
? `<button id="session-grid-${s.id}" class="btn" type="button">${t("events.open_grid")}</button>`
: ""
}
${
event.mode === "race" && ["qualification", "final"].includes(s.type)
? `
<button id="session-sheet-print-${s.id}" class="btn" type="button">${t("events.print_heat_sheet")}</button>
<button id="session-sheet-export-${s.id}" class="btn" type="button">${t("events.export_heat_sheet")}</button>
<button id="session-sheet-pdf-${s.id}" class="btn" type="button">${t("events.pdf_heat_sheet")}</button>
`
: ""
}
<button id="session-delete-${s.id}" class="btn btn-danger">${t("common.delete")}</button>
</div>
</details>
</td>
</tr>
`;
})
)}
})
)}
</details>`;
}).join("")}
</div>
</div>
</section>
+27
View File
@@ -36,3 +36,30 @@ export function groupEventsForList(events = [], getSessions = () => [], today =
};
return { today: byDay(groups.today, false), upcoming: byDay(groups.upcoming, false), done: byDay(groups.done, true) };
}
// A race's sessions (already in running order) split into steps: practice, each qualifying
// round, finals, anything else. Consecutive sessions of one step form one group; a group is
// "done" when all its sessions are run, "live" when one runs.
export function groupSessionsBySteps(sessions = []) {
const stepOf = (session) => {
if (["practice", "free_practice", "open_practice"].includes(session.type)) return { id: "practice" };
if (session.type === "qualification") {
const round = Number(String(session.name || "").match(/^Q(\d+)\s+H\d+/i)?.[1] || 0);
return round ? { id: `qual_${round}`, round } : { id: "qual" };
}
if (session.type === "final") return { id: "final" };
return { id: `other_${session.type}`, type: session.type };
};
const groups = [];
sessions.forEach((session, index) => {
const step = stepOf(session);
const last = groups[groups.length - 1];
if (last && last.step.id === step.id) last.items.push({ session, index });
else groups.push({ key: `${step.id}_${groups.length}`, step, items: [{ session, index }] });
});
return groups.map((group) => {
const done = group.items.filter(({ session }) => ["finished", "stopped"].includes(session.status)).length;
const live = group.items.some(({ session }) => ["running", "paused"].includes(session.status));
return { ...group, done, state: live ? "live" : done === group.items.length ? "done" : "pending" };
});
}
+13
View File
@@ -4825,3 +4825,16 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
.event-row { grid-template-columns: 1fr; }
.event-row-actions { justify-content: flex-start; }
}
/* Race Setup → Manage: sessions grouped per step, done steps folded, rare actions in ⋯ */
.session-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface-card); }
.session-group > summary { display: flex; gap: 12px; align-items: baseline; padding: 10px 12px; cursor: pointer; list-style: revert; }
.session-group > summary small { color: var(--muted); }
.session-group.is-done > summary strong { color: var(--ok); }
.session-group.is-live { border-color: var(--ok); }
.session-group[open] > summary { border-bottom: 1px solid var(--line); }
.session-row-actions { position: relative; }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-list { position: absolute; right: 0; z-index: 20; display: grid; gap: 6px; min-width: 200px; padding: 8px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
+7
View File
@@ -120,4 +120,11 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState,
assert.ok(await evaluate(`[...document.querySelectorAll("[data-event-row]")].some((row) => row.hidden)`), "other races are filtered out");
}
console.log("PASS Race Setup groups races into today, upcoming and a folded Done list, with search");
// Manage: sessions grouped per step; print/export/delete live in the ⋯ menu.
await click("event-manage-" + raceId);
await waitFor(async () => Boolean(await evaluate(`document.querySelector('details[data-session-group="qual_1"]')`)), "qualifying round 1 is its own group");
assert.equal(await evaluate(`document.querySelector('details[data-session-group="qual_1"]').open`), true, "a step not yet run is open");
assert.equal(await evaluate(`Boolean(document.getElementById("session-delete-${q11.id}").closest("details.row-menu"))`), true, "delete is in the ⋯ menu");
console.log("PASS Manage groups sessions per step with the rarer actions in a ⋯ menu");
}
+14
View File
@@ -30,3 +30,17 @@ test("progress says what is running or next and how many are run", () => {
assert.deepEqual(getEventProgress(events[0], getSessions("a")), { total: 2, done: 1, live: "", next: "Q1 H2" });
assert.equal(getEventProgress(events[3], getSessions("d")).live, "Q1 H1");
});
test("a race's sessions are grouped per step, and a step with every heat run is done", async () => {
const { groupSessionsBySteps } = await import("../src/race_list_logic.js");
const groups = groupSessionsBySteps([
s("p", "x", "Seeding", "finished", "practice"),
s("q1", "x", "Q1 H1", "finished"), s("q2", "x", "Q1 H2", "finished"),
s("q3", "x", "Q2 H1", "running"), s("q4", "x", "Q2 H2"),
s("b", "x", "B Final 1", "ready", "final"), s("a", "x", "A Final 1", "ready", "final"),
]);
assert.deepEqual(groups.map((group) => [group.step.id, group.items.length, group.state]), [
["practice", 1, "done"], ["qual_1", 2, "done"], ["qual_2", 2, "live"], ["final", 2, "pending"],
]);
assert.equal(groups[3].items[0].index, 5, "keeps each session's place in the whole list");
});