feat(series): seeding practice in groups split on the series standings (1.45.0)

This commit is contained in:
larssand committed 2026-10-31 22:52:18 +01:00
1 parent 80e0c5308a
commit e7eaa0561e
11 files changed
+112 -21

No files matched your search

+47 -5
View File
@@ -15,7 +15,7 @@ import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudio
import { renderRaceFormatField, renderRaceFormatContextCard, getRaceSummaryItems, getRaceSummaryWarnings, renderManageStatusBadge, renderRaceWizardSteps, renderRaceWizardContent, renderRaceStandingsTable } from "./race_setup_ui.js";
import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, applyBumpsForRace as applyBumpsForRaceLogic, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder } from "./event_race_logic.js";
import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, applyBumpsForRace as applyBumpsForRaceLogic, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder, planSeedingGroups } from "./event_race_logic.js";
import { getSessionTypeLabel as getSessionTypeLabelLogic, getStatusLabel as getStatusLabelLogic, isUntimedSession as isUntimedSessionLogic, getActiveSession as getActiveSessionLogic, getLiveSession as getLiveSessionLogic, getSessionTargetMs as getSessionTargetMsLogic, getSessionLapWindow as getSessionLapWindowLogic, isCountedPassing as isCountedPassingLogic, getVisiblePassings as getVisiblePassingsLogic, getPassingValidationLabel as getPassingValidationLabelLogic, getSessionTiming as getSessionTimingLogic, ensureSessionResult as ensureSessionResultLogic, buildLeaderboard as buildLeaderboardLogic, formatLapDelta as formatLapDeltaLogic, formatLeaderboardGap as formatLeaderboardGapLogic, getCompetitorElapsedMs as getCompetitorElapsedMsLogic, getCompetitorPassings as getCompetitorPassingsLogic, getCompetitorSeedMetric as getCompetitorSeedMetricLogic, getSessionEntrants as getSessionEntrantsLogic, buildPracticeStandings as buildPracticeStandingsLogic, getQualifyingPointsValue as getQualifyingPointsValueLogic, isHighPointsTable as isHighPointsTableLogic, compareNumberSet as compareNumberSetLogic, buildQualifyingTieBreakNote as buildQualifyingTieBreakNoteLogic, hasQualifyingPrimaryTie as hasQualifyingPrimaryTieLogic, buildQualifyingStandings as buildQualifyingStandingsLogic, formatTeamActiveMemberLabel as formatTeamActiveMemberLabelLogic, buildTeamRaceStandings as buildTeamRaceStandingsLogic, buildSessionChannelStats as buildSessionChannelStatsLogic, buildTeamStintLog as buildTeamStintLogLogic, getSessionGridEntries as getSessionGridEntriesLogic, getSessionGridOrder as getSessionGridOrderLogic, ensureSessionDriverOrder as ensureSessionDriverOrderLogic, buildFinalStandings as buildFinalStandingsLogic, getTrackRecordMs as getTrackRecordMsLogic } from "./timing_logic.js";
import { normalizeTrackLayouts, getTrackLayoutIdAt, getTrackLayoutLabel, nextTrackLayoutLabel, findRaceSessionBlockingLayoutChange, isPracticeSessionType, isTrackLayoutInUse } from "./track_layouts_logic.js";
@@ -575,7 +575,7 @@ const getSeriesStandings = (series) => buildSeriesStandings(series, {
classNames: new Map(state.classes.map((item) => [item.id, item.name])),
});
// One race per date and class, named "<series> #<round> <class>", with the chosen race format.
const createSeriesEvents = (series, dates, presetId, format = {}, { heatOrder = "", seedPractice = false, seedPracticeMin = 5, seedLaps = 3, seedMethod = "consecutive" } = {}) => {
const createSeriesEvents = (series, dates, presetId, format = {}, { heatOrder = "", seedPractice = false, seedPracticeMin = 5, seedLaps = 3, seedMethod = "consecutive", seedGroupSize = 0 } = {}) => {
const existingDates = new Set(state.events.filter((event) => series.eventIds.includes(event.id)).map((event) => event.date));
const allDates = [...new Set([...existingDates, ...dates])].sort();
let created = 0;
@@ -591,6 +591,7 @@ const createSeriesEvents = (series, dates, presetId, format = {}, { heatOrder =
// A practice before qualifying seeds the heats (no driver list: it follows the round's
// participants, set later).
if (seedPractice) {
event.raceConfig.seedGroupSize = Math.max(0, Math.round(Number(seedGroupSize) || 0));
state.sessions.push(buildRaceSession(event.id, t("series.seed_practice_name"), "practice", Math.max(1, Math.round(seedPracticeMin)), {
startMode: "mass", seedBestLapCount: seedLaps, seedMethod,
}));
@@ -642,6 +643,7 @@ const setSeriesRoundFormat = (eventId, values) => {
config.finalLegs = Math.max(1, Math.round(Number(values.finalLegs ?? config.finalLegs) || 1));
config.carsPerHeat = Math.max(2, Math.round(Number(values.carsPerHeat ?? config.carsPerHeat) || 2));
config.carsPerFinal = Math.max(2, Math.round(Number(values.carsPerHeat ?? config.carsPerFinal) || config.carsPerFinal || 2));
config.seedGroupSize = Math.max(0, Math.round(Number(values.seedGroupSize ?? config.seedGroupSize) || 0));
// Two of three finals count (or all, with fewer than three).
config.countedFinalLegs = config.finalLegs >= 3 ? config.finalLegs - 1 : config.finalLegs;
config.presetId = "custom";
@@ -688,6 +690,38 @@ const generateSeriesRoundFinals = (eventId) => {
saveState();
return created;
};
// Today's drivers in series-standings order (class table), the rest after them in entry
// order - the first round, and guests in a members-only series.
const rankForSeeding = (event) => {
const series = (state.series || []).find((item) => item.eventIds.includes(event.id));
const table = series ? getSeriesStandings(series).find((item) => item.classId === event.classId) : null;
const rank = new Map((table?.rows || []).map((row) => [row.driverId, row.rank]));
return getEventDrivers(event).map((driver, index) => ({ id: driver.id, index }))
.sort((a, b) => (rank.get(a.id) ?? Infinity) - (rank.get(b.id) ?? Infinity) || a.index - b.index)
.map((item) => item.id);
};
// The round's seeding practice is (re)split into groups from today's drivers each time it is
// opened, until one group has started - so late entries and unticked drivers are taken in.
const prepareSeedingGroups = (eventId) => {
const event = findSeriesEvent(eventId);
const seeding = event ? getSessionsForEvent(eventId).filter((session) => session.type === "practice") : [];
if (!seeding.length || seeding.some((session) => session.status !== "ready")) return;
const groups = planSeedingGroups(rankForSeeding(event), event.raceConfig.seedGroupSize, event.raceConfig.heatOrder);
if (!groups.length) return;
const template = seeding[0];
const oldIds = new Set(seeding.map((session) => session.id));
if (oldIds.has(state.activeSessionId)) state.activeSessionId = null;
state.sessions = state.sessions.filter((session) => !oldIds.has(session.id));
const baseName = t("series.seed_practice_name");
groups.forEach((driverIds, index) => state.sessions.push(buildRaceSession(event.id, groups.length > 1 ? `${baseName} ${index + 1}` : baseName, "practice", template.durationMin, {
driverIds, startMode: template.startMode, seedBestLapCount: template.seedBestLapCount, seedMethod: template.seedMethod,
})));
};
const runSeriesSeeding = (eventId) => {
prepareSeedingGroups(eventId);
const step = getSeriesRoundNextStep(getSessionsForEvent(eventId));
if (step.session) runSeriesSession(step.session.id);
};
// The row's run button: make the session the active one and go to Race Day, where only
// Start is left to press.
const runSeriesSession = (sessionId) => {
@@ -731,7 +765,7 @@ const exportSeriesPdf = async (series, tables) => {
)),
});
};
const renderSeries = () => renderSeriesView({ state, dom, t, escapeHtml, saveState, renderView, uid, getClassName, getSeriesStandings, createSeriesEvents, getRaceFormatPresets, exportSeriesPdf, printSeries, getSeriesRounds, deleteSeriesRaces, runSeriesSession, 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, runSeriesSession, runSeriesSeeding, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound });
const renderArchive = () => renderResultsArchiveView({
state, dom, t, escapeHtml, formatLap, formatRaceClock, renderTable,
getClassName, getEventName, buildLeaderboard, getCompetitorPassings,
@@ -1026,6 +1060,10 @@ const TRANSLATIONS = {
"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.",
"series.run_seeding": "Seedningsträning",
"series.run_seeding_groups": "Seedningsträning ({count} grupper)",
"series.seed_group_size": "Max förare per seedningsgrupp",
"series.col_seed_group": "Seedgrupp",
"series.col_seed_group_hint": "Max förare per seedningsgrupp (0 = alla i samma). Grupperna delas efter serieställningen när du trycker ▶ Seedningsträning.",
"series.run_session": "Kör {name}",
"series.show_live": "Pågår: {name}",
"series.skip_seeding": "Hoppa över – generera kval",
@@ -1652,7 +1690,7 @@ const TRANSLATIONS = {
"guide.series_day_1": "1. Allt görs i tabellen i steg 3, en rad per race (datum och klass).",
"guide.series_day_2": "2. Klicka på antalet förare och bocka ur dem som inte kör. Kopiera från förra tar samma startfält som förra deltävlingen i klassen; Ny förare lägger in en efteranmäld förare och bockar i hen.",
"guide.series_day_3": "3. Ändra vid behov antal kval, finaler och max bilar per heat för just den deltävlingen - det kan skilja mellan deltävlingar och klasser.",
"guide.series_day_4": "4. Knappen på raden visar nästa steg. Börja med ▶ Seedningsträning: den väljer klassens träning och öppnar Race Day - tryck Starta. Kör alla klassers träningar först om ni har flera klasser.",
"guide.series_day_4": "4. Knappen på raden visar nästa steg. Börja med ▶ Seedningsträning: den delar dagens förare i seedningsgrupper (max enligt kolumnen Seedgrupp, efter serieställningen - första deltävlingen i anmälningsordning), väljer första gruppen och öppnar Race Day - tryck Starta. Sedan ▶ Seedningsträning 2 osv. Grupperna delas om tills första gruppen startat, så efteranmälda kommer med.",
"guide.series_day_5": "5. Skapa kval: heaten delas efter träningstiderna (lika snabba tillsammans, snabbaste heatet sist) och jämnt efter fältet (9 förare, max 6 -> 5 + 4). Sedan visar raden ▶ Kör Q1 H1, Q1 H2 ... och på Race Day väljer ▶ Nästa nästa heat. Reseeda kommande kval (i racet under Race Setup) delar om efter kvalrankingen.",
"guide.series_day_6": "6. När kvalet är klart: Skapa finaler, sedan ▶ Kör C Final 1, B Final 1, A Final 1, C Final 2 ... Status visar var deltävlingen är. Öppna tar dig till racet i Race Setup. Ställningen i steg 4 uppdateras av sig själv.",
"guide.series_points_title": "Poäng och ställning",
@@ -2891,6 +2929,10 @@ const TRANSLATIONS = {
"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.",
"series.run_seeding": "Seeding practice",
"series.run_seeding_groups": "Seeding practice ({count} groups)",
"series.seed_group_size": "Max drivers per seeding group",
"series.col_seed_group": "Seed group",
"series.col_seed_group_hint": "Max drivers per seeding group (0 = all together). The groups are split on the series standings when you press ▶ Seeding practice.",
"series.run_session": "Run {name}",
"series.show_live": "Running: {name}",
"series.skip_seeding": "Skip – generate qualifying",
@@ -3517,7 +3559,7 @@ const TRANSLATIONS = {
"guide.series_day_1": "1. Everything is done in the table in step 3, one row per race (date and class).",
"guide.series_day_2": "2. Click the number of drivers and untick those not racing. Copy from previous takes the field of the previous round in the class; New driver registers a late entry and ticks them.",
"guide.series_day_3": "3. Change qualifying rounds, finals and max cars per heat for that round if needed - it can differ between rounds and classes.",
"guide.series_day_4": "4. The button on the row shows the next step. Start with ▶ Seeding practice: it selects the class's practice and opens Race Day - press Start. With several classes, run every class's practice first.",
"guide.series_day_4": "4. The button on the row shows the next step. Start with ▶ Seeding practice: it splits today's drivers into seeding groups (max per the Seed group column, on the series standings - entry order in the first round), selects the first group and opens Race Day - press Start. Then ▶ Seeding practice 2 and so on. The groups are re-split until the first one has started, so late entries are included.",
"guide.series_day_5": "5. Create qualifying: the heats are split on the practice times (equal pace together, fastest heat last) and evenly by the field (9 drivers, max 6 -> 5 + 4). The row then shows ▶ Run Q1 H1, Q1 H2 ... and on Race Day ▶ Next selects the next heat. Reseed upcoming qualifying (in the race under Race Setup) re-splits on the qualifying standings.",
"guide.series_day_6": "6. When qualifying is done: Create finals, then ▶ Run C Final 1, B Final 1, A Final 1, C Final 2 ... Status shows where the round is. Open goes to the race in Race Setup. The standings in step 4 update by themselves.",
"guide.series_points_title": "Points and standings",
+13
View File
@@ -216,6 +216,7 @@ export function buildRaceFormatConfigFromForm(form, event, { normalizeStartMode,
bumpCount: Math.max(0, Number(form.get("bumpCount") || 0) || 0),
reserveBumpSlots: form.get("reserveBumpSlots") === "on",
heatOrder: normalizeHeatOrder(form.get("heatOrder") ?? event.raceConfig.heatOrder),
seedGroupSize: Math.max(0, Math.round(Number(form.get("seedGroupSize") ?? event.raceConfig.seedGroupSize) || 0)),
driverIds: event.raceConfig.driverIds || [],
participantsConfigured: event.raceConfig.participantsConfigured !== false,
finalsSource: String(form.get("finalsSource") || "qualifying") === "practice" ? "practice" : "qualifying",
@@ -261,6 +262,8 @@ export function normalizeEvent(event, { normalizeBrandingConfig, normalizeStartM
bumpCount: Math.max(0, Number(event?.raceConfig?.bumpCount || 0) || 0),
reserveBumpSlots: event?.raceConfig?.reserveBumpSlots !== false,
heatOrder: normalizeHeatOrder(event?.raceConfig?.heatOrder),
// Max drivers per seeding-practice group (series rounds); 0 = everyone in one practice.
seedGroupSize: Math.max(0, Math.round(Number(event?.raceConfig?.seedGroupSize) || 0)),
driverIds: Array.isArray(event?.raceConfig?.driverIds) ? event.raceConfig.driverIds : [],
participantsConfigured: Boolean(event?.raceConfig?.participantsConfigured),
finalsSource: event?.raceConfig?.finalsSource === "practice" ? "practice" : "qualifying",
@@ -662,6 +665,16 @@ export function normalizeHeatOrder(value) {
return HEAT_ORDERS.includes(String(value || "")) ? String(value) : "fastest_first";
}
// Seeding practice in groups of at most groupSize (0 = everyone together), split evenly like
// heats. rankedDriverIds come best first (the series standings), so drivers close in the
// standings share a group, and the heat order decides whether the top group runs last.
export function planSeedingGroups(rankedDriverIds, groupSize, heatOrder) {
const ids = [...new Set((rankedDriverIds || []).filter(Boolean))];
if (!ids.length) return [];
const size = Number(groupSize) > 0 ? Math.round(Number(groupSize)) : ids.length;
return buildSeededHeats(ids, Math.max(1, size), heatOrder);
}
// Seeded rows (fastest first) split into heats in running order (heat 1 first).
export function buildSeededHeats(rows, carsPerHeat, heatOrder) {
const heats = splitIntoBalancedGroups(rows, carsPerHeat);
+3 -1
View File
@@ -175,7 +175,9 @@ export function getSeriesRoundNextStep(sessions = []) {
const has = (type) => ordered.some((session) => session.type === type);
if (!has("qualification")) {
const practice = ready("practice");
return practice ? { kind: "seeding", session: practice } : { kind: "make_qualifying" };
// notStarted: no seeding group has run yet (the groups can still be re-split).
const notStarted = ordered.filter((session) => session.type === "practice").every((session) => session.status === "ready");
return practice ? { kind: "seeding", session: practice, notStarted } : { kind: "make_qualifying" };
}
const heat = ready("qualification");
if (heat) return { kind: "qualifying", session: heat };
+14 -4
View File
@@ -92,7 +92,13 @@ function renderNextStep(round, { t, escapeHtml }) {
const run = (label, live = false) => `<button class="btn btn-go btn-mini" type="button" data-round-action="run" data-round-session="${escapeHtml(step.session.id)}" title="${escapeHtml(t("series.run_hint"))}" ${live ? "" : noDrivers}>${live ? "●" : "▶"} ${escapeHtml(label)}</button>`;
const makeQualifying = (label, primary) => `<button class="btn ${primary ? "btn-primary" : ""} btn-mini" type="button" data-round-action="qualifying" ${noDrivers}>${escapeHtml(label)}</button>`;
if (step.kind === "live") return run(t("series.show_live", { name: step.session.name }), true);
if (step.kind === "seeding") return run(t("series.run_seeding")) + makeQualifying(t("series.skip_seeding"), false);
if (step.kind === "seeding") {
// Before the first group starts, the label says how many groups today's field gives.
const size = Number(round.event.raceConfig?.seedGroupSize) || 0;
const groups = step.notStarted && size > 0 ? Math.ceil(round.participantIds.length / size) : 1;
const label = !step.notStarted ? step.session.name : groups > 1 ? t("series.run_seeding_groups", { count: groups }) : t("series.run_seeding");
return run(label).replace('data-round-action="run"', 'data-round-action="seeding"') + (step.notStarted ? makeQualifying(t("series.skip_seeding"), false) : "");
}
if (step.kind === "make_qualifying") return makeQualifying(t("series.make_qualifying"), true);
if (step.kind === "qualifying" || step.kind === "final") return run(t("series.run_session", { name: step.session.name }));
if (step.kind === "make_finals") return `<button class="btn btn-primary btn-mini" type="button" data-round-action="finals">${t("series.make_finals")}</button>`;
@@ -104,7 +110,7 @@ function renderRoundsTable(rounds, { t, escapeHtml }) {
const number = (round, name, value, min) => `<input class="series-round-number" type="number" min="${min}" name="${name}" value="${value}" ${round.status === "not_started" ? "" : "disabled"} />`;
return `
<div class="table-wrap"><table class="series-rounds-table">
<thead><tr><th>${t("series.col_date")}</th><th>${t("series.col_race")}</th><th>${t("series.col_drivers")}</th><th title="${escapeHtml(t("series.col_qual_hint"))}">${t("series.col_qual_short")}</th><th>${t("series.col_finals")}</th><th>${t("series.col_per_heat")}</th><th>${t("series.col_status")}</th><th></th></tr></thead>
<thead><tr><th>${t("series.col_date")}</th><th>${t("series.col_race")}</th><th>${t("series.col_drivers")}</th><th title="${escapeHtml(t("series.col_qual_hint"))}">${t("series.col_qual_short")}</th><th>${t("series.col_finals")}</th><th>${t("series.col_per_heat")}</th><th title="${escapeHtml(t("series.col_seed_group_hint"))}">${t("series.col_seed_group")}</th><th>${t("series.col_status")}</th><th></th></tr></thead>
<tbody>${rounds.map((round) => {
const config = round.event.raceConfig || {};
const action = renderNextStep(round, { t, escapeHtml });
@@ -116,10 +122,11 @@ function renderRoundsTable(rounds, { t, escapeHtml }) {
<td>${number(round, "qualifyingRounds", config.qualifyingRounds || 1, 1)}</td>
<td>${number(round, "finalLegs", config.finalLegs || 1, 1)}</td>
<td>${number(round, "carsPerHeat", config.carsPerHeat || 8, 2)}</td>
<td>${number(round, "seedGroupSize", config.seedGroupSize || 0, 0)}</td>
<td><span class="pill series-status-${round.status}">${t(`series.status_${round.status}`)}</span>${round.qualHeatCount ? `<br><small>${t("series.heats_made", { heats: round.qualHeatCount })}</small>` : ""}</td>
<td><div class="series-round-actions">${action}<button class="btn btn-mini" type="button" data-round-action="open">${t("series.open_race")}</button><button class="btn btn-mini" type="button" data-round-action="remove" title="${escapeHtml(t("series.remove_round"))}">✕</button></div></td>
</tr>
${expandedRoundId === round.event.id ? `<tr class="series-round-detail"><td colspan="8">${renderRoundParticipants(round, { t, escapeHtml })}</td></tr>` : ""}`;
${expandedRoundId === round.event.id ? `<tr class="series-round-detail"><td colspan="9">${renderRoundParticipants(round, { t, escapeHtml })}</td></tr>` : ""}`;
}).join("")}</tbody>
</table></div>`;
}
@@ -156,7 +163,7 @@ function renderStandingsTable(table, { t, escapeHtml }) {
export function renderSeriesView(deps) {
const {
state, dom, t, escapeHtml, saveState, renderView, uid, getClassName, getSeriesStandings, createSeriesEvents, getRaceFormatPresets, exportSeriesPdf, printSeries,
getSeriesRounds, deleteSeriesRaces, runSeriesSession, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound,
getSeriesRounds, deleteSeriesRaces, runSeriesSession, runSeriesSeeding, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound,
} = deps;
const list = state.series || [];
if (!list.some((item) => item.id === selectedSeriesId)) selectedSeriesId = list[0]?.id || "";
@@ -187,6 +194,7 @@ export function renderSeriesView(deps) {
<label><span>${t("series.seed_practice_min")}</span><input type="number" min="1" name="seedPracticeMin" value="5" /></label>
<label><span>${t("series.seed_method")}</span><select name="seedMethod">${[["consecutive", 3], ["best_sum", 3], ["average", 3], ["best_lap", 0]].map(([method]) => `<option value="${method}">${t(method === "best_lap" ? "series.seed_best_lap" : `events.seed_method_${method}`)}</option>`).join("")}</select></label>
<label><span>${t("series.seed_laps")}</span><input type="number" min="1" name="seedLaps" value="3" /></label>
<label><span>${t("series.seed_group_size")}</span><input type="number" min="0" name="seedGroupSize" value="6" /></label>
<label><span>${t("events.heat_order")}</span><select name="heatOrder">${["fastest_last", "fastest_first"].map((order) => `<option value="${order}">${t(`events.heat_order_${order}`)}</option>`).join("")}</select></label>
<p class="hint series-create-hint">${t("series.seed_hint")}</p>
<div class="series-create-actions"><button class="btn btn-primary" type="submit" ${series.classIds.length ? "" : "disabled"}>${t("series.create_events")}</button></div>
@@ -277,6 +285,7 @@ export function renderSeriesView(deps) {
// "Best lap" = no lap-count metric: practice is then ranked on each driver's best lap.
seedLaps: seedMethod === "best_lap" ? 0 : Math.max(1, Number(data.get("seedLaps")) || 3),
seedMethod: seedMethod === "best_lap" ? "best_sum" : seedMethod,
seedGroupSize: Math.max(0, Number(data.get("seedGroupSize")) || 0),
});
renderView();
// Always say what happened: clicking again for dates already in the series creates nothing.
@@ -306,6 +315,7 @@ export function renderSeriesView(deps) {
if (action === "toggle") expandedRoundId = expandedRoundId === eventId ? "" : eventId;
if (action === "open") { openSeriesRound(eventId); return; }
if (action === "run") { runSeriesSession(button.dataset.roundSession); return; }
if (action === "seeding") { runSeriesSeeding(eventId); return; }
if (action === "qualifying" && !generateSeriesRoundQualifying(eventId)) window.alert(t("series.no_participants"));
if (action === "finals") generateSeriesRoundFinals(eventId);
if (action === "remove") {