fix(team-race): edit teams and length while the race runs; quick length picks (1.67.1)

This commit is contained in:
larssand committed 2026-11-05 22:05:20 +01:00
1 parent 37076b8490
commit a9146d9662
5 files changed
+36 -11

No files matched your search

+5
View File
@@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet. 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 ## 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. - 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.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.67.0", "version": "1.67.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.67.0", "version": "1.67.1",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"better-sqlite3": "^12.11.1", "better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.67.0", "version": "1.67.1",
"private": true, "private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": { "engines": {
+2
View File
@@ -2866,6 +2866,7 @@ const TRANSLATIONS = {
"team_setup.length_min": "Längd (minuter)", "team_setup.length_min": "Längd (minuter)",
"team_setup.create_race": "Skapa lagrace", "team_setup.create_race": "Skapa lagrace",
"team_setup.locked": "Lagracet är {status} – lagen kan inte ändras.", "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.unplaced": "Inte i något lag: {names}",
"team_setup.issue_no_teams": "Minst två lag behövs.", "team_setup.issue_no_teams": "Minst två lag behövs.",
"team_setup.issue_empty": "{team} har inga förare.", "team_setup.issue_empty": "{team} har inga förare.",
@@ -4938,6 +4939,7 @@ const TRANSLATIONS = {
"team_setup.length_min": "Length (minutes)", "team_setup.length_min": "Length (minutes)",
"team_setup.create_race": "Create team race", "team_setup.create_race": "Create team race",
"team_setup.locked": "The team race is {status} – the teams can't be changed.", "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.unplaced": "On no team: {names}",
"team_setup.issue_no_teams": "At least two teams are needed.", "team_setup.issue_no_teams": "At least two teams are needed.",
"team_setup.issue_empty": "{team} has no drivers.", "team_setup.issue_empty": "{team} has no drivers.",
+26 -8
View File
@@ -3,6 +3,13 @@
// Logic in team_race_logic.js; this file only renders and binds. // 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"; 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) { export function mountTeamRaceSetup(root, deps) {
if (!root) return; if (!root) return;
const { event, state, t, escapeHtml, uid, saveState, refresh, getSessionsForEvent, getEventTeams, getTeamDriverPool, normalizeSession, getStatusLabel } = deps; 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 pool = getTeamDriverPool(event);
const poolIds = pool.drivers.map((driver) => driver.id); const poolIds = pool.drivers.map((driver) => driver.id);
const session = getSessionsForEvent(event.id).find((item) => item.type === "team_race") || null; 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 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 issues = findTeamRaceIssues(teams, { drivers: state.drivers, cars: state.cars, driverIds: pool.fallback ? [] : poolIds });
const driver = (id) => state.drivers.find((item) => item.id === id); const driver = (id) => state.drivers.find((item) => item.id === id);
@@ -55,16 +65,21 @@ export function mountTeamRaceSetup(root, deps) {
<p class="hint">${t("team_setup.intro")}</p> <p class="hint">${t("team_setup.intro")}</p>
${pool.fallback ? `<p class="hint">${t("events.team_driver_fallback")}</p>` : ""} ${pool.fallback ? `<p class="hint">${t("events.team_driver_fallback")}</p>` : ""}
<h4>${t("team_setup.step_teams")}</h4> <h4>${t("team_setup.step_teams")}</h4>
${editable ? `<div class="actions team-setup-toolbar"> ${live ? `<p class="hint">${t("team_setup.live_hint")}</p>` : ""}
${editable && !live ? `<div class="actions team-setup-toolbar">
<label><span>${t("team_setup.team_count")}</span><input type="number" id="teamSetupCount" min="2" max="30" step="1" value="${Math.max(2, teams.length || Math.min(4, Math.ceil(poolIds.length / 2)) || 2)}" /></label> <label><span>${t("team_setup.team_count")}</span><input type="number" id="teamSetupCount" min="2" max="30" step="1" value="${Math.max(2, teams.length || Math.min(4, Math.ceil(poolIds.length / 2)) || 2)}" /></label>
<button class="btn btn-primary" type="button" id="teamSetupSplit">${t("team_setup.split")}</button> <button class="btn btn-primary" type="button" id="teamSetupSplit">${t("team_setup.split")}</button>
<button class="btn" type="button" id="teamSetupAdd">${t("team_setup.add_team")}</button> <button class="btn" type="button" id="teamSetupAdd">${t("team_setup.add_team")}</button>
</div>` : `<p class="hint">${t("team_setup.locked", { status: getStatusLabel(session.status) })}</p>`} </div>` : ""}
${editable && live ? `<div class="actions team-setup-toolbar"><button class="btn" type="button" id="teamSetupAdd">${t("team_setup.add_team")}</button></div>` : ""}
${editable ? "" : `<p class="hint">${t("team_setup.locked", { status: getStatusLabel(session.status) })}</p>`}
<div class="team-setup-grid mt-16">${teams.map(teamCard).join("") || `<p>${t("events.no_teams")}</p>`}</div> <div class="team-setup-grid mt-16">${teams.map(teamCard).join("") || `<p>${t("events.no_teams")}</p>`}</div>
${unplaced.length ? `<p class="hint mt-8">${t("team_setup.unplaced", { names: unplaced.join(", ") })}</p>` : ""} ${unplaced.length ? `<p class="hint mt-8">${t("team_setup.unplaced", { names: unplaced.join(", ") })}</p>` : ""}
<h4 class="mt-16">${t("team_setup.step_format")}</h4> <h4 class="mt-16">${t("team_setup.step_format")}</h4>
<div class="actions team-setup-toolbar"> <div class="actions team-setup-toolbar">
<label><span>${t("team_setup.length_min")}</span><input type="number" id="teamSetupLength" min="1" max="1440" step="1" value="${lengthMin}" ${disabled} /></label> <label><span>${t("team_setup.length_min")}</span><input type="number" id="teamSetupLength" min="1" max="1440" step="1" value="${lengthMin}" ${disabled} /></label>
${editable ? LENGTH_PRESETS.map((minutes) => `<button class="btn btn-mini ${minutes === lengthMin ? "btn-primary" : ""}" type="button" data-team-length="${minutes}">${escapeHtml(formatLength(minutes))}</button>`).join("") : ""}
<span class="hint">= ${escapeHtml(formatLength(lengthMin))}</span>
${session ${session
? `<span class="pill">${escapeHtml(session.name)} · ${escapeHtml(getStatusLabel(session.status))}</span>` ? `<span class="pill">${escapeHtml(session.name)} · ${escapeHtml(getStatusLabel(session.status))}</span>`
: `<button class="btn btn-primary" type="button" id="teamSetupCreate">${t("team_setup.create_race")}</button>`} : `<button class="btn btn-primary" type="button" id="teamSetupCreate">${t("team_setup.create_race")}</button>`}
@@ -78,7 +93,7 @@ export function mountTeamRaceSetup(root, deps) {
// Saves the teams; the team race (if not started) follows: its drivers and length. // Saves the teams; the team race (if not started) follows: its drivers and length.
const save = (nextTeams) => { const save = (nextTeams) => {
event.raceConfig = { ...(event.raceConfig || {}), teams: nextTeams.filter((team) => team.name) }; 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(); saveState();
refresh(); 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-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-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.querySelectorAll("[data-team-delete]").forEach((button) => button.addEventListener("click", () => save(removeTeam(teams, button.dataset.teamDelete))));
root.querySelector("#teamSetupLength")?.addEventListener("change", (changeEvent) => { // A running race can be made longer or shorter too: the clock follows.
const minutes = Math.max(1, Math.round(Number(changeEvent.currentTarget.value) || lengthMin)); const setLength = (value) => {
const minutes = Math.max(1, Math.round(Number(value) || lengthMin));
event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes }; event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes };
if (session && session.status === "ready") session.durationMin = minutes; if (session && editable) session.durationMin = minutes;
saveState(); saveState();
refresh(); 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", () => { root.querySelector("#teamSetupCreate")?.addEventListener("click", () => {
const minutes = Math.max(1, Math.round(Number(root.querySelector("#teamSetupLength").value) || lengthMin)); const minutes = Math.max(1, Math.round(Number(root.querySelector("#teamSetupLength").value) || lengthMin));
event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes }; event.raceConfig = { ...(event.raceConfig || {}), teamRaceDurationMin: minutes };