diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7b050..e16d38a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,17 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.43.1 - 2026-10-31 + +### Fixed + +- **Series: "Create races" always says what it did.** It reports how many races were made, or that none were because the series' classes already have races on those dates - clicking again used to do nothing at all, with no message. +- **Deleting a series can take its races along.** After confirming the delete, a second question asks whether the series' races (with heats and results) should be removed from Race Setup too, or kept, e.g. for the results archive. Races that also belong to another series are kept. + +### Changed + +- **Race Day: shorter session list.** The session picker shows today's races, plus anything running or selected, grouped per race in the order they were set up. Old races, practices and other series' rounds are hidden behind "Show all sessions". + ## 1.43.0 - 2026-10-31 ### Added diff --git a/package-lock.json b/package-lock.json index c7699e6..199edea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.43.0", + "version": "1.43.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.43.0", + "version": "1.43.1", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index d4caf4b..524936c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.43.0", + "version": "1.43.1", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 9cea1c5..fda3a26 100644 --- a/src/app.js +++ b/src/app.js @@ -620,6 +620,17 @@ const getSeriesRounds = (series) => state.events finalCount: sessions.filter((session) => session.type === "final").length, }; }); +// Deleting a series can take its rounds along (races in another series are kept). +const deleteSeriesRaces = (series) => { + const inOtherSeries = new Set((state.series || []).filter((item) => item.id !== series.id).flatMap((item) => item.eventIds)); + const eventIds = new Set(series.eventIds.filter((id) => !inOtherSeries.has(id))); + const sessionIds = state.sessions.filter((session) => eventIds.has(session.eventId)).map((session) => session.id); + state.events = state.events.filter((event) => !eventIds.has(event.id)); + state.sessions = state.sessions.filter((session) => !eventIds.has(session.eventId)); + sessionIds.forEach((id) => delete state.resultsBySession[id]); + if (sessionIds.includes(state.activeSessionId)) state.activeSessionId = null; + void purgeSessionPassings(sessionIds); +}; const findSeriesEvent = (eventId) => state.events.find((event) => event.id === eventId) || null; // Format per round (can differ between rounds and classes); locked once qualifying exists. const setSeriesRoundFormat = (eventId, values) => { @@ -713,7 +724,7 @@ const exportSeriesPdf = async (series, tables) => { )), }); }; -const renderSeries = () => renderSeriesView({ state, dom, t, escapeHtml, saveState, renderView, uid, getClassName, getSeriesStandings, createSeriesEvents, getRaceFormatPresets, exportSeriesPdf, printSeries, getSeriesRounds, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound }); +const renderSeries = () => renderSeriesView({ state, dom, t, escapeHtml, saveState, renderView, uid, getClassName, getSeriesStandings, createSeriesEvents, getRaceFormatPresets, exportSeriesPdf, printSeries, getSeriesRounds, deleteSeriesRaces, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound }); const renderArchive = () => renderResultsArchiveView({ state, dom, t, escapeHtml, formatLap, formatRaceClock, renderTable, getClassName, getEventName, buildLeaderboard, getCompetitorPassings, @@ -898,6 +909,8 @@ const TRANSLATIONS = { "race_day.quick_layout": "Ny banlayout", "race_day.quick_race": "Skapa race", "race_day.pick_session": "Session", + "race_day.show_all_sessions": "Visa alla sessioner", + "race_day.hidden_sessions": "({count} från andra dagar dolda)", "race_day.reset_session_hint": "Nollställer sessionens varv och resultat, t.ex. vid omstart. Pausa först om heatet körs.", "race_day.reset_session_confirm": "Nollställ alla varv och resultat i \"{name}\"?\n\nDet går inte att ångra.", "race_day.new_practice_day": "Nollställ – ny träningsdag", @@ -1000,7 +1013,10 @@ const TRANSLATIONS = { "series.counted_of": "{counted} räknas av {completed} körda ({total} planerade)", "series.no_results": "Inga körda deltävlingar ännu.", "series.legend": "Siffra = seriepoäng. (Inom parentes) = struket resultat. – = deltog inte. Lika poäng: flest segrar, sedan andraplatser osv., sedan senaste gemensamma deltävling.", - "series.delete_confirm": "Ta bort serien \"{name}\"? Racen och deras resultat finns kvar.", + "series.delete_confirm": "Ta bort serien \"{name}\"?", + "series.delete_races_confirm": "Ta också bort seriens {count} race från Race Setup, med heat och resultat?\n\nOK = ta bort racen\nAvbryt = behåll racen (t.ex. för resultatarkivet)", + "series.created_rounds": "{count} race skapade. De finns i listan nedan och under Race Setup.", + "series.created_none": "Inga nya race skapades: seriens klasser har redan race på de datumen.", "nav.race_setup": "Race Setup", "nav.race_setup_sub": "Open Practice, klubbrace och endurance", "nav.overlay": "Overlay", @@ -2752,6 +2768,8 @@ const TRANSLATIONS = { "race_day.quick_layout": "New track layout", "race_day.quick_race": "Create race", "race_day.pick_session": "Session", + "race_day.show_all_sessions": "Show all sessions", + "race_day.hidden_sessions": "({count} from other days hidden)", "race_day.reset_session_hint": "Clears the session's laps and results, e.g. for a restart. Pause first if the heat is running.", "race_day.reset_session_confirm": "Clear every lap and result in \"{name}\"?\n\nThis cannot be undone.", "race_day.new_practice_day": "Reset – new practice day", @@ -2854,7 +2872,10 @@ const TRANSLATIONS = { "series.counted_of": "{counted} counted of {completed} run ({total} planned)", "series.no_results": "No rounds run yet.", "series.legend": "Number = series points. (In brackets) = dropped result. – = did not take part. Ties: most wins, then 2nd places etc., then the latest common round.", - "series.delete_confirm": "Delete the series \"{name}\"? The races and their results are kept.", + "series.delete_confirm": "Delete the series \"{name}\"?", + "series.delete_races_confirm": "Also delete the series' {count} races from Race Setup, with heats and results?\n\nOK = delete the races\nCancel = keep the races (e.g. for the results archive)", + "series.created_rounds": "{count} races created. They are listed below and under Race Setup.", + "series.created_none": "No new races were created: the series' classes already have races on those dates.", "nav.race_setup": "Race Setup", "nav.race_setup_sub": "Open Practice, club races and endurance", "nav.overlay": "Overlay", diff --git a/src/race_day_view.js b/src/race_day_view.js index 1ba478b..d984778 100644 --- a/src/race_day_view.js +++ b/src/race_day_view.js @@ -64,6 +64,33 @@ function renderQueueSession(session, positionKey, deps) { // count-down, and the check panel shows who has crossed the line since. The panel re-renders // on its own (refreshRaceDayWarmup) on every passing, without rebuilding the page. let lastWarmupDeps = null; +let showAllSessions = false; + +const localDateKey = (date = new Date()) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`; + +// The session picker lists today's races by default (plus whatever is live or selected), +// grouped per race in the order they were set up. Old races, practices and other series' +// rounds stay out of the way until "Show all" is ticked. Undated races show unrun sessions. +export function buildRaceDaySessionGroups({ sessions, events, selectedId = "", showAll = false, today = localDateKey() }) { + const eventById = new Map((events || []).map((event) => [event.id, event])); + const isLive = (session) => ["running", "paused"].includes(session.status); + const visible = (session) => { + if (showAll || isLive(session) || session.id === selectedId) return true; + const date = eventById.get(session.eventId)?.date; + return date ? date === today : session.status === "ready"; + }; + const groups = new Map(); + let hidden = 0; + (sessions || []).forEach((session) => { + if (!visible(session)) { hidden += 1; return; } + if (!groups.has(session.eventId)) groups.set(session.eventId, { event: eventById.get(session.eventId) || null, sessions: [] }); + groups.get(session.eventId).sessions.push(session); + }); + const list = [...groups.values()].sort((a, b) => + Number(b.sessions.some(isLive)) - Number(a.sessions.some(isLive)) + || String(b.event?.date || "").localeCompare(String(a.event?.date || ""))); + return { groups: list, hidden }; +} function showsWarmupPanel(session) { return Boolean(session && session.status === "ready" && session.mode !== "track" && session.type !== "team_race" && !isPracticeSessionType(session.type)); @@ -210,10 +237,7 @@ export function renderRaceDayView(deps) { const practiceLabel = !practice ? t("race_day.quick_practice_new") : practice.status === "running" ? t("race_day.quick_practice_show", { name: practice.name }) : t("race_day.quick_practice_continue", { name: practice.name }); - const sessionChoices = state.sessions.slice().sort((a, b) => { - const rank = (item) => (["running", "paused"].includes(item.status) ? 0 : item.status === "ready" ? 1 : 2); - return rank(a) - rank(b) || Number(b.startedAt || 0) - Number(a.startedAt || 0); - }); + const sessionChoices = buildRaceDaySessionGroups({ sessions: state.sessions, events: state.events, selectedId: session?.id, showAll: showAllSessions }); const isPracticeSession = Boolean(session && (isPracticeSessionType(session.type) || session.type === "practice")); const isLiveSession = ["running", "paused"].includes(session?.status); // Layouts are a practice thing: never offered while a race session is in focus. @@ -248,9 +272,12 @@ export function renderRaceDayView(deps) { + ${sessionChoices.hidden || showAllSessions ? `` : ""} ${session && !isSelected ? `` : ""}