feat(series): next-step button per round and Race Day next session (1.44.0)

This commit is contained in:
larssand committed 2026-10-31 09:03:34 +01:00
1 parent dbda06d101
commit 71aa149a4d
12 files changed
+145 -10

No files matched your search

+18 -4
View File
@@ -84,6 +84,21 @@ function renderRoundParticipants(round, { t, escapeHtml }) {
</div>`;
}
// One button for what comes next in the round: seeding practice, make qualifying, the next
// heat, make finals, the next final. "Run" selects the session and opens Race Day.
function renderNextStep(round, { t, escapeHtml }) {
const step = round.nextStep || {};
const noDrivers = round.participantIds.length ? "" : "disabled";
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 === "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>`;
return "";
}
function renderRoundsTable(rounds, { t, escapeHtml }) {
if (!rounds.length) return `<p class="hint">${t("series.no_rounds")}</p>`;
const number = (round, name, value, min) => `<input class="series-round-number" type="number" min="${min}" name="${name}" value="${value}" ${round.status === "not_started" ? "" : "disabled"} />`;
@@ -92,9 +107,7 @@ function renderRoundsTable(rounds, { t, escapeHtml }) {
<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>
<tbody>${rounds.map((round) => {
const config = round.event.raceConfig || {};
const action = round.status === "not_started"
? `<button class="btn btn-primary btn-mini" type="button" data-round-action="qualifying" ${round.participantIds.length ? "" : "disabled"}>${t("series.make_qualifying")}</button>`
: round.status === "qual_done" ? `<button class="btn btn-primary btn-mini" type="button" data-round-action="finals">${t("series.make_finals")}</button>` : "";
const action = renderNextStep(round, { t, escapeHtml });
return `
<tr data-round="${escapeHtml(round.event.id)}" class="${expandedRoundId === round.event.id ? "is-expanded" : ""}">
<td>${escapeHtml(round.event.date || t("series.no_date"))}</td>
@@ -143,7 +156,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, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound,
getSeriesRounds, deleteSeriesRaces, runSeriesSession, setSeriesRoundFormat, setSeriesRoundParticipants, copySeriesRoundParticipants, addDriverToSeriesRound, generateSeriesRoundQualifying, generateSeriesRoundFinals, openSeriesRound,
} = deps;
const list = state.series || [];
if (!list.some((item) => item.id === selectedSeriesId)) selectedSeriesId = list[0]?.id || "";
@@ -292,6 +305,7 @@ export function renderSeriesView(deps) {
const action = button.dataset.roundAction;
if (action === "toggle") expandedRoundId = expandedRoundId === eventId ? "" : eventId;
if (action === "open") { openSeriesRound(eventId); return; }
if (action === "run") { runSeriesSession(button.dataset.roundSession); return; }
if (action === "qualifying" && !generateSeriesRoundQualifying(eventId)) window.alert(t("series.no_participants"));
if (action === "finals") generateSeriesRoundFinals(eventId);
if (action === "remove") {