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

+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") {