feat(race-setup): group a race's sessions per step, fold run steps, rare actions in a menu (1.53.0)
This commit is contained in:
1 parent
b23410c190
commit
73e3d1ff75
12 files changed
+147
-25
No files matched your search
+12
@@ -2226,6 +2226,12 @@ const TRANSLATIONS = {
|
||||
"events.session_max_cars_hint": "Sätt gräns om just den sessionen bara ska ha ett visst antal bilar.",
|
||||
"events.edit_session_help": "Ändra sessionens namn, typ, tid och seed-/startinställningar här.",
|
||||
"events.set_active": "Sätt aktiv",
|
||||
"events.more_actions": "Fler val: utskrift, export, grid, ta bort",
|
||||
"events.step_practice": "Träning / seedning",
|
||||
"events.step_qual_round": "Kval omgång {round}",
|
||||
"events.step_qual": "Kval",
|
||||
"events.step_finals": "Finaler",
|
||||
"events.step_count": "{done}/{total} körda",
|
||||
"events.assignments": "Tilldelningar",
|
||||
"events.na": "ej relevant",
|
||||
"events.sponsor_tools": "Sponsorverktyg",
|
||||
@@ -4174,6 +4180,12 @@ const TRANSLATIONS = {
|
||||
"events.session_max_cars_hint": "Set a limit if this session should only allow a certain number of cars.",
|
||||
"events.edit_session_help": "Edit the session name, type, timing and seed/start settings here.",
|
||||
"events.set_active": "Set Active",
|
||||
"events.more_actions": "More: print, export, grid, delete",
|
||||
"events.step_practice": "Practice / seeding",
|
||||
"events.step_qual_round": "Qualifying round {round}",
|
||||
"events.step_qual": "Qualifying",
|
||||
"events.step_finals": "Finals",
|
||||
"events.step_count": "{done}/{total} run",
|
||||
"events.assignments": "Assignments",
|
||||
"events.na": "n/a",
|
||||
"events.sponsor_tools": "Sponsor Event Tools",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { orderSessionsForRunning, moveSessionInRunningOrder } from "./event_race_logic.js";
|
||||
import { setSessionGroupOpen } from "./event_manager_view.js";
|
||||
let activeManageTab = "setup";
|
||||
// Maps a data-target anchor id (used by the step-card overview and the race-summary
|
||||
// warning links) to the tab it now lives inside, so jumping to it also switches tabs
|
||||
@@ -215,6 +216,9 @@ export function renderEventManagerView(context) {
|
||||
getModeLabel,
|
||||
renderTable,
|
||||
});
|
||||
eventManageArea.querySelectorAll("details[data-session-group]").forEach((group) => {
|
||||
group.addEventListener("toggle", () => setSessionGroupOpen(event.id, group.dataset.sessionGroup, group.open));
|
||||
});
|
||||
|
||||
const manageTabButtons = Array.from(eventManageArea.querySelectorAll(".manage-tab"));
|
||||
const manageTabPanels = Array.from(eventManageArea.querySelectorAll("[data-manage-panel]"));
|
||||
|
||||
+57
-22
@@ -1,4 +1,19 @@
|
||||
import { PROLOGUE_OPTIONS_SEC, formatPrologueOption } from "./prologue_logic.js";
|
||||
import { groupSessionsBySteps } from "./race_list_logic.js";
|
||||
|
||||
// Done steps are folded; one the operator opened stays open across re-renders (this page only).
|
||||
const openSessionGroups = new Set();
|
||||
export const isSessionGroupOpen = (eventId, stepId) => openSessionGroups.has(`${eventId}:${stepId}`);
|
||||
// A ⋯ menu closes when anything outside it is clicked.
|
||||
if (typeof document !== "undefined") {
|
||||
document.addEventListener("click", (event) => {
|
||||
document.querySelectorAll("details.row-menu[open]").forEach((menu) => { if (!menu.contains(event.target)) menu.open = false; });
|
||||
});
|
||||
}
|
||||
export function setSessionGroupOpen(eventId, stepId, open) {
|
||||
if (open) openSessionGroups.add(`${eventId}:${stepId}`);
|
||||
else openSessionGroups.delete(`${eventId}:${stepId}`);
|
||||
}
|
||||
function formatDateTimeLocalValue(ms) {
|
||||
const date = new Date(ms);
|
||||
date.setSeconds(0, 0);
|
||||
@@ -163,10 +178,23 @@ export function renderEventManagerMarkup(context) {
|
||||
<p class="hint">${t("events.free_practice_note")}</p>
|
||||
<p class="hint">${t("events.open_practice_note")}</p>
|
||||
|
||||
<div class="mt-16">
|
||||
${renderTable(
|
||||
[t("table.session"), t("table.type"), t("table.duration"), t("table.start_mode"), t("table.seeding"), t("table.status"), t(event.mode === "track" ? "events.assignments" : "events.participants"), t("events.actions")],
|
||||
sessions.map((s, sessionIndex) => {
|
||||
<div class="mt-16 session-groups">
|
||||
${groupSessionsBySteps(sessions).map((group) => {
|
||||
const title = group.step.id === "practice" ? t("events.step_practice")
|
||||
: group.step.round ? t("events.step_qual_round", { round: group.step.round })
|
||||
: group.step.id === "qual" ? t("events.step_qual")
|
||||
: group.step.id === "final" ? t("events.step_finals")
|
||||
: getSessionTypeLabel(group.step.type);
|
||||
const open = group.state !== "done" || isSessionGroupOpen(event.id, group.step.id);
|
||||
return `
|
||||
<details class="session-group is-${group.state}" data-session-group="${escapeHtml(group.step.id)}" ${open ? "open" : ""}>
|
||||
<summary>
|
||||
<strong>${group.state === "done" ? "✓ " : group.state === "live" ? '<span class="live-dot" aria-hidden="true"></span> ' : ""}${escapeHtml(title)}</strong>
|
||||
<small>${escapeHtml(t("events.step_count", { done: group.done, total: group.items.length }))}</small>
|
||||
</summary>
|
||||
${renderTable(
|
||||
[t("table.session"), t("table.type"), t("table.duration"), t("table.start_mode"), t("table.seeding"), t("table.status"), t(event.mode === "track" ? "events.assignments" : "events.participants"), t("events.actions")],
|
||||
group.items.map(({ session: s, index: sessionIndex }) => {
|
||||
const assignCount =
|
||||
event.mode === "track"
|
||||
? (s.assignments || []).length
|
||||
@@ -182,31 +210,38 @@ export function renderEventManagerMarkup(context) {
|
||||
<td>${s.seedBestLapCount > 0 ? `${s.seedBestLapCount}` : "-"}</td>
|
||||
<td>${escapeHtml(getStatusLabel(s.status))}</td>
|
||||
<td>${assignCount || (event.mode === "track" ? t("events.na") : "-")}</td>
|
||||
<td class="actions-inline">
|
||||
<td class="actions-inline session-row-actions">
|
||||
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="-1" title="${escapeHtml(t("events.move_session_up"))}" ${sessionIndex ? "" : "disabled"}>▲</button>
|
||||
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="1" title="${escapeHtml(t("events.move_session_down"))}" ${sessionIndex < sessions.length - 1 ? "" : "disabled"}>▼</button>
|
||||
<button id="session-edit-${s.id}" class="btn">${t("events.edit_session")}</button>
|
||||
<button id="session-active-${s.id}" class="btn">${t("events.set_active")}</button>
|
||||
${
|
||||
event.mode === "race" && normalizeStartMode(s.startMode) === "position"
|
||||
? `<button id="session-grid-${s.id}" class="btn" type="button">${t("events.open_grid")}</button>`
|
||||
: ""
|
||||
}
|
||||
${
|
||||
event.mode === "race" && ["qualification", "final"].includes(s.type)
|
||||
? `
|
||||
<button id="session-sheet-print-${s.id}" class="btn" type="button">${t("events.print_heat_sheet")}</button>
|
||||
<button id="session-sheet-export-${s.id}" class="btn" type="button">${t("events.export_heat_sheet")}</button>
|
||||
<button id="session-sheet-pdf-${s.id}" class="btn" type="button">${t("events.pdf_heat_sheet")}</button>
|
||||
`
|
||||
: ""
|
||||
}
|
||||
<button id="session-delete-${s.id}" class="btn btn-danger">${t("common.delete")}</button>
|
||||
<details class="row-menu">
|
||||
<summary class="btn btn-mini" title="${escapeHtml(t("events.more_actions"))}">⋯</summary>
|
||||
<div class="row-menu-list">
|
||||
${
|
||||
event.mode === "race" && normalizeStartMode(s.startMode) === "position"
|
||||
? `<button id="session-grid-${s.id}" class="btn" type="button">${t("events.open_grid")}</button>`
|
||||
: ""
|
||||
}
|
||||
${
|
||||
event.mode === "race" && ["qualification", "final"].includes(s.type)
|
||||
? `
|
||||
<button id="session-sheet-print-${s.id}" class="btn" type="button">${t("events.print_heat_sheet")}</button>
|
||||
<button id="session-sheet-export-${s.id}" class="btn" type="button">${t("events.export_heat_sheet")}</button>
|
||||
<button id="session-sheet-pdf-${s.id}" class="btn" type="button">${t("events.pdf_heat_sheet")}</button>
|
||||
`
|
||||
: ""
|
||||
}
|
||||
<button id="session-delete-${s.id}" class="btn btn-danger">${t("common.delete")}</button>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
})
|
||||
)}
|
||||
})
|
||||
)}
|
||||
</details>`;
|
||||
}).join("")}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -36,3 +36,30 @@ export function groupEventsForList(events = [], getSessions = () => [], today =
|
||||
};
|
||||
return { today: byDay(groups.today, false), upcoming: byDay(groups.upcoming, false), done: byDay(groups.done, true) };
|
||||
}
|
||||
|
||||
// A race's sessions (already in running order) split into steps: practice, each qualifying
|
||||
// round, finals, anything else. Consecutive sessions of one step form one group; a group is
|
||||
// "done" when all its sessions are run, "live" when one runs.
|
||||
export function groupSessionsBySteps(sessions = []) {
|
||||
const stepOf = (session) => {
|
||||
if (["practice", "free_practice", "open_practice"].includes(session.type)) return { id: "practice" };
|
||||
if (session.type === "qualification") {
|
||||
const round = Number(String(session.name || "").match(/^Q(\d+)\s+H\d+/i)?.[1] || 0);
|
||||
return round ? { id: `qual_${round}`, round } : { id: "qual" };
|
||||
}
|
||||
if (session.type === "final") return { id: "final" };
|
||||
return { id: `other_${session.type}`, type: session.type };
|
||||
};
|
||||
const groups = [];
|
||||
sessions.forEach((session, index) => {
|
||||
const step = stepOf(session);
|
||||
const last = groups[groups.length - 1];
|
||||
if (last && last.step.id === step.id) last.items.push({ session, index });
|
||||
else groups.push({ key: `${step.id}_${groups.length}`, step, items: [{ session, index }] });
|
||||
});
|
||||
return groups.map((group) => {
|
||||
const done = group.items.filter(({ session }) => ["finished", "stopped"].includes(session.status)).length;
|
||||
const live = group.items.some(({ session }) => ["running", "paused"].includes(session.status));
|
||||
return { ...group, done, state: live ? "live" : done === group.items.length ? "done" : "pending" };
|
||||
});
|
||||
}
|
||||
@@ -4825,3 +4825,16 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
|
||||
.event-row { grid-template-columns: 1fr; }
|
||||
.event-row-actions { justify-content: flex-start; }
|
||||
}
|
||||
|
||||
/* Race Setup → Manage: sessions grouped per step, done steps folded, rare actions in ⋯ */
|
||||
.session-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface-card); }
|
||||
.session-group > summary { display: flex; gap: 12px; align-items: baseline; padding: 10px 12px; cursor: pointer; list-style: revert; }
|
||||
.session-group > summary small { color: var(--muted); }
|
||||
.session-group.is-done > summary strong { color: var(--ok); }
|
||||
.session-group.is-live { border-color: var(--ok); }
|
||||
.session-group[open] > summary { border-bottom: 1px solid var(--line); }
|
||||
.session-row-actions { position: relative; }
|
||||
.row-menu { position: relative; display: inline-block; }
|
||||
.row-menu > summary { list-style: none; cursor: pointer; }
|
||||
.row-menu > summary::-webkit-details-marker { display: none; }
|
||||
.row-menu-list { position: absolute; right: 0; z-index: 20; display: grid; gap: 6px; min-width: 200px; padding: 8px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
|
||||
Reference in new issue
Block a user