feat(race-day): fold run heats in today's schedule and mark the next heat (1.54.0)
This commit is contained in:
1 parent
73e3d1ff75
commit
d0248b1960
9 files changed
+44
-12
No files matched your search
+9
-1
@@ -375,6 +375,7 @@ const AUTOPILOT_STORAGE_KEY = "rc_day_autopilot";
|
||||
let autopilotDate = (() => { try { return sessionStorage.getItem(AUTOPILOT_STORAGE_KEY) || ""; } catch { return ""; } })();
|
||||
let autopilotStatus = "";
|
||||
let autopilotLaunchingId = null;
|
||||
let dayShowDone = false;
|
||||
const todayKey = () => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; };
|
||||
const getDayPlan = (date) => getRaceDay(state.raceDays, date);
|
||||
const saveDayPlan = (day) => { state.raceDays = upsertRaceDay(state.raceDays, day); saveState(); };
|
||||
@@ -499,7 +500,7 @@ function moveDaySession(date, sessionId, step) {
|
||||
const formatDayClock = (ts) => formatClockTime(ts);
|
||||
const renderDaySchedule = () => {
|
||||
const date = getRaceDayDate();
|
||||
return renderDaySchedulePanel({ t, escapeHtml, date, day: getDayPlan(date), rows: buildDayRows(date), autopilotHere: autopilotDate === date, autopilotStatus: autopilotDate === date ? autopilotStatus : "", getClassLabel: getDayClassLabel });
|
||||
return renderDaySchedulePanel({ t, escapeHtml, date, day: getDayPlan(date), rows: buildDayRows(date), autopilotHere: autopilotDate === date, autopilotStatus: autopilotDate === date ? autopilotStatus : "", getClassLabel: getDayClassLabel, showDone: dayShowDone });
|
||||
};
|
||||
const bindDaySchedule = (root) => {
|
||||
const date = getRaceDayDate();
|
||||
@@ -514,6 +515,7 @@ const bindDaySchedule = (root) => {
|
||||
setAutopilot(date, on);
|
||||
},
|
||||
onPause: () => pauseRaceDay(date),
|
||||
onToggleDone: () => { dayShowDone = !dayShowDone; renderView(); },
|
||||
onResume: () => resumeRaceDay(date),
|
||||
});
|
||||
};
|
||||
@@ -2871,6 +2873,9 @@ const TRANSLATIONS = {
|
||||
"day.board": "Förarvy",
|
||||
"day.start_time": "Första start",
|
||||
"day.gap": "Paus mellan heat (min)",
|
||||
"day.show_done": "✓ {count} heat körda – visa",
|
||||
"day.hide_done": "Dölj körda heat ({count})",
|
||||
"day.next": "Nästa",
|
||||
"day.call_min": "Upprop (min innan)",
|
||||
"day.call_title": "{name} startar {time} (om {min} min) – dags att ropa upp",
|
||||
"day.call_now": "Ropa ut",
|
||||
@@ -4825,6 +4830,9 @@ const TRANSLATIONS = {
|
||||
"day.board": "Drivers' board",
|
||||
"day.start_time": "First start",
|
||||
"day.gap": "Break between heats (min)",
|
||||
"day.show_done": "✓ {count} heats run – show",
|
||||
"day.hide_done": "Hide run heats ({count})",
|
||||
"day.next": "Next",
|
||||
"day.call_min": "Call (min before)",
|
||||
"day.call_title": "{name} starts at {time} (in {min} min) – time to call it",
|
||||
"day.call_now": "Call now",
|
||||
|
||||
@@ -18,8 +18,11 @@ function stateLabel(row, t, now) {
|
||||
return "";
|
||||
}
|
||||
|
||||
export function renderDaySchedulePanel({ t, escapeHtml, date, day, rows, autopilotHere, autopilotStatus, getClassLabel, now = Date.now() }) {
|
||||
export function renderDaySchedulePanel({ t, escapeHtml, date, day, rows, autopilotHere, autopilotStatus, getClassLabel, showDone = false, now = Date.now() }) {
|
||||
if (!rows.length) return "";
|
||||
// Run heats fold into one line so what is left of the day is on top.
|
||||
const doneCount = rows.filter((row) => row.state === "done").length;
|
||||
const nextId = rows.find((row) => row.state === "upcoming")?.session.id;
|
||||
return `
|
||||
<section class="panel mt-16 day-schedule" id="daySchedule">
|
||||
<div class="panel-header">
|
||||
@@ -48,10 +51,11 @@ export function renderDaySchedulePanel({ t, escapeHtml, date, day, rows, autopil
|
||||
<table class="day-schedule-table">
|
||||
<thead><tr><th>${escapeHtml(t("day.col_time"))}</th><th>${escapeHtml(t("day.col_session"))}</th><th>${escapeHtml(t("day.col_drivers"))}</th><th></th><th></th></tr></thead>
|
||||
<tbody>
|
||||
${rows.map((row, index) => `
|
||||
<tr class="is-${row.state} ${row.delayed ? "is-delayed" : ""}" data-day-row="${escapeHtml(row.session.id)}">
|
||||
${doneCount ? `<tr class="day-done-toggle"><td colspan="5"><button class="btn btn-mini" type="button" id="dayToggleDone">${escapeHtml(t(showDone ? "day.hide_done" : "day.show_done", { count: doneCount }))}</button></td></tr>` : ""}
|
||||
${rows.map((row, index) => row.state === "done" && !showDone ? "" : `
|
||||
<tr class="is-${row.state} ${row.session.id === nextId ? "is-next" : ""} ${row.delayed ? "is-delayed" : ""}" data-day-row="${escapeHtml(row.session.id)}">
|
||||
<td><strong>${formatClockTime(row.start)}</strong>${row.delayed && row.state !== "done" ? ` <small class="day-planned">(${formatClockTime(row.plannedStart)})</small>` : ""}</td>
|
||||
<td>${escapeHtml(rowLabel(row, getClassLabel))}</td>
|
||||
<td>${row.session.id === nextId ? `<span class="pill">${escapeHtml(t("day.next"))}</span> ` : ""}${escapeHtml(rowLabel(row, getClassLabel))}</td>
|
||||
<td>${row.driverCount ?? ""}</td>
|
||||
<td><small>${escapeHtml(stateLabel(row, t, now))}</small></td>
|
||||
<td class="day-move">
|
||||
@@ -90,7 +94,8 @@ export function bindDayCallBanner(root, { onCall, onLater }) {
|
||||
root.querySelector("#dayCallLater")?.addEventListener("click", () => onLater(sessionId));
|
||||
}
|
||||
|
||||
export function bindDaySchedulePanel(root, { date, onSavePlan, onMove, onPrint, onBoard, onAutopilot, onPause, onResume }) {
|
||||
export function bindDaySchedulePanel(root, { date, onSavePlan, onMove, onPrint, onBoard, onAutopilot, onPause, onResume, onToggleDone = () => {} }) {
|
||||
root.querySelector("#dayToggleDone")?.addEventListener("click", onToggleDone);
|
||||
root.querySelector("#dayPlanForm")?.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const form = new FormData(event.currentTarget);
|
||||
|
||||
+3
-1
@@ -4776,7 +4776,9 @@ tr.is-removed td.lap-actions {
|
||||
.day-schedule-table th { text-align: left; font-size: 0.8rem; color: var(--muted); padding: 6px 8px; }
|
||||
.day-schedule-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
|
||||
.day-schedule-table tr.is-done { opacity: 0.55; }
|
||||
.day-schedule-table tr.is-live td { background: rgba(38, 194, 129, 0.12); }
|
||||
.day-schedule-table tr.is-live td { background: rgba(38, 194, 129, 0.16); font-weight: 700; }
|
||||
.day-schedule-table tr.is-next td { background: rgba(245, 166, 35, 0.10); }
|
||||
.day-schedule-table tr.day-done-toggle td { padding: 4px 8px; }
|
||||
.day-schedule-table .day-planned, .day-schedule-table tr.is-delayed td:first-child strong { color: var(--warn); }
|
||||
.day-schedule-table .day-move { white-space: nowrap; text-align: right; }
|
||||
.driver-board { padding: 16px; display: grid; gap: 16px; color: var(--text); }
|
||||
|
||||
Reference in new issue
Block a user