From a9146d96622ce74622850964fe37b059dc5ab172 Mon Sep 17 00:00:00 2001 From: larssand Date: Thu, 5 Nov 2026 22:05:20 +0100 Subject: [PATCH] fix(team-race): edit teams and length while the race runs; quick length picks (1.67.1) --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- src/app.js | 2 ++ src/team_race_setup_view.js | 34 ++++++++++++++++++++++++++-------- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c25071d..44241b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.67.1 + +- Team race: the teams can still be changed while the race runs (a wrong transponder, a broken car swapped for another): laps stay with the team, a change counts from the next passing. Locked only once the race is finished. +- Team race length: quick picks 30 min, 1 h, 2 h, 4 h, 6 h, 12 h and 24 h, and the length is shown in hours. It can be changed while the race runs too. + ## 1.67.0 - Team race setup in one panel (Events → Manage), replacing the separate team form, checkbox lists and edit window: 1 teams and drivers (split the chosen drivers over N teams in one click, rename a team in place, add a driver from a list that says which team they move from, remove with ×), a car per team or the drivers' own transponders, 2 the length, with "Create team race" when there is no team race session yet, 3 the checks before the start (fewer than two teams, a team without drivers or transponder, a transponder on two teams, drivers on no team). Shown as soon as the endurance format is picked. Locked once the race has started. diff --git a/package-lock.json b/package-lock.json index f510be7..2ddeb2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.67.0", + "version": "1.67.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.67.0", + "version": "1.67.1", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index a9defc2..395cf22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.67.0", + "version": "1.67.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 50f5875..7f30251 100644 --- a/src/app.js +++ b/src/app.js @@ -2866,6 +2866,7 @@ const TRANSLATIONS = { "team_setup.length_min": "Längd (minuter)", "team_setup.create_race": "Skapa lagrace", "team_setup.locked": "Lagracet är {status} – lagen kan inte ändras.", + "team_setup.live_hint": "Lagracet pågår. Du kan fortfarande byta förare, bil och transponder – ändringen gäller från nästa passering och varven som körts stannar hos laget.", "team_setup.unplaced": "Inte i något lag: {names}", "team_setup.issue_no_teams": "Minst två lag behövs.", "team_setup.issue_empty": "{team} har inga förare.", @@ -4938,6 +4939,7 @@ const TRANSLATIONS = { "team_setup.length_min": "Length (minutes)", "team_setup.create_race": "Create team race", "team_setup.locked": "The team race is {status} – the teams can't be changed.", + "team_setup.live_hint": "The team race is on. You can still change drivers, car and transponder – it counts from the next passing and the laps already done stay with the team.", "team_setup.unplaced": "On no team: {names}", "team_setup.issue_no_teams": "At least two teams are needed.", "team_setup.issue_empty": "{team} has no drivers.", diff --git a/src/team_race_setup_view.js b/src/team_race_setup_view.js index c840d23..5023a71 100644 --- a/src/team_race_setup_view.js +++ b/src/team_race_setup_view.js @@ -3,6 +3,13 @@ // Logic in team_race_logic.js; this file only renders and binds. import { splitIntoTeams, moveDriverToTeam, setTeamCar, renameTeam, removeTeam, getTeamTransponders, findTeamRaceIssues } from "./team_race_logic.js"; +const LENGTH_PRESETS = [30, 60, 120, 240, 360, 720, 1440]; +const formatLength = (minutes) => { + const hours = Math.floor(minutes / 60); + const rest = minutes % 60; + return hours ? `${hours} h${rest ? ` ${rest} min` : ""}` : `${rest} min`; +}; + export function mountTeamRaceSetup(root, deps) { if (!root) return; const { event, state, t, escapeHtml, uid, saveState, refresh, getSessionsForEvent, getEventTeams, getTeamDriverPool, normalizeSession, getStatusLabel } = deps; @@ -10,7 +17,10 @@ export function mountTeamRaceSetup(root, deps) { const pool = getTeamDriverPool(event); const poolIds = pool.drivers.map((driver) => driver.id); const session = getSessionsForEvent(event.id).find((item) => item.type === "team_race") || null; - const editable = !session || session.status === "ready"; + // Teams stay editable while the race runs (wrong transponder, a broken car swapped): laps are + // kept per team, so a change only counts from the next passing. Locked once it is finished. + const editable = !session || !["finished", "stopped"].includes(session.status); + const live = Boolean(session && ["running", "paused"].includes(session.status)); const lengthMin = Math.max(1, Number(session?.durationMin || event.raceConfig?.teamRaceDurationMin || 60) || 60); const issues = findTeamRaceIssues(teams, { drivers: state.drivers, cars: state.cars, driverIds: pool.fallback ? [] : poolIds }); const driver = (id) => state.drivers.find((item) => item.id === id); @@ -55,16 +65,21 @@ export function mountTeamRaceSetup(root, deps) {

${t("team_setup.intro")}

${pool.fallback ? `

${t("events.team_driver_fallback")}

` : ""}

${t("team_setup.step_teams")}

- ${editable ? `
+ ${live ? `

${t("team_setup.live_hint")}

` : ""} + ${editable && !live ? `
-
` : `

${t("team_setup.locked", { status: getStatusLabel(session.status) })}

`} +
` : ""} + ${editable && live ? `
` : ""} + ${editable ? "" : `

${t("team_setup.locked", { status: getStatusLabel(session.status) })}

`}
${teams.map(teamCard).join("") || `

${t("events.no_teams")}

`}
${unplaced.length ? `

${t("team_setup.unplaced", { names: unplaced.join(", ") })}

` : ""}

${t("team_setup.step_format")}

+ ${editable ? LENGTH_PRESETS.map((minutes) => ``).join("") : ""} + = ${escapeHtml(formatLength(lengthMin))} ${session ? `${escapeHtml(session.name)} · ${escapeHtml(getStatusLabel(session.status))}` : ``} @@ -78,7 +93,7 @@ export function mountTeamRaceSetup(root, deps) { // Saves the teams; the team race (if not started) follows: its drivers and length. const save = (nextTeams) => { event.raceConfig = { ...(event.raceConfig || {}), teams: nextTeams.filter((team) => team.name) }; - if (session && session.status === "ready") session.driverIds = [...new Set(nextTeams.flatMap((team) => team.driverIds))]; + if (session && editable) session.driverIds = [...new Set(nextTeams.flatMap((team) => team.driverIds))]; saveState(); refresh(); }; @@ -95,13 +110,16 @@ export function mountTeamRaceSetup(root, deps) { root.querySelectorAll("[data-team-remove-driver]").forEach((button) => button.addEventListener("click", () => save(moveDriverToTeam(teams, button.dataset.teamRemoveDriver, "")))); root.querySelectorAll("[data-team-car]").forEach((select) => select.addEventListener("change", () => save(setTeamCar(teams, select.dataset.teamCar, select.value)))); root.querySelectorAll("[data-team-delete]").forEach((button) => button.addEventListener("click", () => save(removeTeam(teams, button.dataset.teamDelete)))); - root.querySelector("#teamSetupLength")?.addEventListener("change", (changeEvent) => { - const minutes = Math.max(1, Math.round(Number(changeEvent.currentTarget.value) || lengthMin)); + // A running race can be made longer or shorter too: the clock follows. + const setLength = (value) => { + const minutes = Math.max(1, Math.round(Number(value) || lengthMin)); event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes }; - if (session && session.status === "ready") session.durationMin = minutes; + if (session && editable) session.durationMin = minutes; saveState(); refresh(); - }); + }; + root.querySelector("#teamSetupLength")?.addEventListener("change", (changeEvent) => setLength(changeEvent.currentTarget.value)); + root.querySelectorAll("[data-team-length]").forEach((button) => button.addEventListener("click", () => setLength(button.dataset.teamLength))); root.querySelector("#teamSetupCreate")?.addEventListener("click", () => { const minutes = Math.max(1, Math.round(Number(root.querySelector("#teamSetupLength").value) || lengthMin)); event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes };