feat(day): one start time - Race setup's start time and gap are Race Day's, with Race Day's times shown (1.89.17)
This commit is contained in:
1 parent
cb29c5471b
commit
f8080ffaeb
11 files changed
+122
-17
No files matched your search
+13
-7
@@ -12,7 +12,7 @@ import { sendHouseOfRcResults, renderHouseOfRcSendStatus } from "./houseofrc_vie
|
||||
import { recordTransponderSighting, buildWarmupCheck, createPrologue, getPrologueRemainingMs, holdPrologue, resumePrologue, setPrologueRemaining, takeDuePrologueCall, formatPrologueTime, getPrologueHandoverMs, normalizePrologueSec, getPrologueMarks } from "./prologue_logic.js";
|
||||
import { findTransponderConflict, getDriverProfileId } from "./driver_profile_logic.js";
|
||||
import { renderRaceDayView, refreshRaceDayWarmup, refreshRaceDayPrologueClock, updateRaceDayStartDisplay, refreshRaceDayLive } from "./race_day_view.js";
|
||||
import { normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate, getDueCall } from "./day_schedule_logic.js";
|
||||
import { normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate, getDueCall, withRaceSetupStart, eventScheduleFromDayRows } from "./day_schedule_logic.js";
|
||||
import { buildRaceOverview, buildRaceOverviewCsvRows, withQualifyingPlaces, qualifyingPlaces } from "./race_overview_logic.js";
|
||||
import { renderRaceOverviewPanel, bindRaceOverviewPanel } from "./race_overview_view.js";
|
||||
import { renderSpeakerPanel, bindSpeakerPanel } from "./speaker_panel_view.js";
|
||||
@@ -146,7 +146,9 @@ const getManualCorrectionSummary = (row) => getManualCorrectionSummaryLogic(row,
|
||||
const renderTeamStintLog = (session, rows) => renderTeamStintLogHelper(session, rows, { t, escapeHtml, buildTeamStintLog, formatTeamActiveMemberLabel, renderTable, formatRaceClock });
|
||||
const renderTeamRaceStandings = (event) => renderTeamRaceStandingsHelper(event, { t, escapeHtml, buildTeamRaceStandings, getSessionTypeLabel, renderTable, formatTeamActiveMemberLabel, formatLap, formatRaceClock, renderTeamStintLog, buildSessionChannelStats });
|
||||
const getSessionSortWeight = (session) => getSessionSortWeightHelper(session);
|
||||
const buildEventSchedule = (event) => buildEventScheduleLogic(event, getSessionsForEvent(event.id));
|
||||
// Race setup and the printed start lists show the times of Today's schedule (Race Day), which
|
||||
// is what the autopilot runs; a race without a date keeps its own simple plan.
|
||||
const buildEventSchedule = (event) => (event?.date ? eventScheduleFromDayRows(buildDayRows(event.date), event.id) : buildEventScheduleLogic(event, getSessionsForEvent(event.id)));
|
||||
const getDriverDisplayById = (driverId) => getDriverDisplayByIdHelper(driverId, { state, t });
|
||||
const renderPositionGrid = (session) => renderPositionGridHelper(session, { t, escapeHtml, getSessionGridEntries });
|
||||
const renderGridEditor = (session) => renderGridEditorHelper(session, { t, escapeHtml, ensureSessionDriverOrder, state });
|
||||
@@ -492,7 +494,7 @@ 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 getDayPlan = (date) => withRaceSetupStart(getRaceDay(state.raceDays, date), state.events);
|
||||
const saveDayPlan = (day) => { state.raceDays = upsertRaceDay(state.raceDays, day); saveState(); };
|
||||
const getDayClassLabel = (session) => { const event = state.events.find((item) => item.id === session.eventId); return event?.classId ? getClassName(event.classId) : event?.name || ""; };
|
||||
function buildDayRows(date, now = Date.now()) {
|
||||
@@ -2433,8 +2435,8 @@ const TRANSLATIONS = {
|
||||
"auth.cancel": "Avbryt",
|
||||
"auth.wrong_pin": "Fel PIN.",
|
||||
"auth.too_many": "För många felaktiga försök. Vänta några minuter.",
|
||||
"guide.schedule_1": "1. Öppna Hantera -> fliken Schema & utskrift för ett race-event. Sätt starttid och paus mellan sessioner (standard 3 minuter) och klicka Spara schema.",
|
||||
"guide.schedule_2": "2. Varje sessions planerade klockslag räknas ut i körordning (practice, sedan kval, sedan finaler) utifrån starttiden, sessionens längd/efterlöp och pausen mellan sessioner.",
|
||||
"guide.schedule_1": "1. Öppna Hantera -> fliken Schema & utskrift för ett race-event. Sätt starttid och paus mellan sessioner (standard 3 minuter) och klicka Spara schema. Det är samma inställning som Första start och Paus mellan heat i Race Day (Dagens schema) för racets datum - ändrar du på ena stället ändras det andra, och Race Day styr.",
|
||||
"guide.schedule_2": "2. Tiderna som visas är Race Days: alla klasser som kör samma dag i körordning, med pauser mellan rundor, före finaler och lunch inräknade. Paus mellan rundor, lunch och ordningen ändrar du i Race Day.",
|
||||
"guide.schedule_3": "3. Så fort en session faktiskt startar eller avslutas flyttas resten av schemat automatiskt fram till den verkliga tiden - en sen start eller en session som drar över (inklusive paus) skjuter resten av dagen framåt utan att du behöver räkna om manuellt. En session som startade mer än en minut sent märks \"Försenad\".",
|
||||
"guide.schedule_4": "4. Det planerade klockslaget skrivs också ut på startlistorna (Skriv ut/PDF startlistor) så förare kan se när deras session ungefär börjar.",
|
||||
"guide.day_flow_title": "Racedag steg för steg: practice → kval → finaler",
|
||||
@@ -2558,6 +2560,7 @@ const TRANSLATIONS = {
|
||||
"events.schedule_title": "Tidsschema",
|
||||
"events.schedule_hint": "Sätt en starttid för dagen så räknas varje sessions planerade klockslag ut automatiskt utifrån längd, efterlöp och paus mellan sessioner. Skjuter en session upp sig (körs över tiden eller pausas) flyttas resten av schemat fram automatiskt.",
|
||||
"events.schedule_start_time": "Starttid",
|
||||
"events.schedule_day_link": "Starttid och paus är samma som Första start i Race Day (Dagens schema) och ändras på båda ställena. Tiderna nedan är Race Days - där lägger du även paus mellan rundor, lunch och flyttar heat.",
|
||||
"events.schedule_gap": "Paus mellan sessioner (min)",
|
||||
"events.schedule_save": "Spara schema",
|
||||
"events.schedule_clear": "Rensa schema",
|
||||
@@ -4733,8 +4736,8 @@ const TRANSLATIONS = {
|
||||
"auth.cancel": "Cancel",
|
||||
"auth.wrong_pin": "Wrong PIN.",
|
||||
"auth.too_many": "Too many failed attempts. Wait a few minutes.",
|
||||
"guide.schedule_1": "1. Open Manage -> the Schedule & print tab for a race event. Set a start time and the gap between sessions (default 3 minutes) and click Save schedule.",
|
||||
"guide.schedule_2": "2. Every session's planned clock time is worked out in running order (practice, then qualifying, then finals) from the start time, each session's own duration/follow-up, and the gap between sessions.",
|
||||
"guide.schedule_1": "1. Open Manage -> the Schedule & print tab for a race event. Set a start time and the gap between sessions (default 3 minutes) and click Save schedule. It is the same setting as First start and Break between heats in Race Day (Today's schedule) for the race's date - change one and the other follows, and Race Day is in charge.",
|
||||
"guide.schedule_2": "2. The times shown are Race Day's: every class running that day in running order, with breaks between rounds, before finals and lunch included. Set breaks between rounds, lunch and the order in Race Day.",
|
||||
"guide.schedule_3": "3. As soon as a session actually starts or finishes, the rest of the schedule automatically shifts to match reality - a late start or a session that runs long (including any pause) pushes the rest of the day forward with no manual recalculation. A session that started more than a minute late is marked \"Delayed\".",
|
||||
"guide.schedule_4": "4. The planned clock time is also printed on the start lists (Print/PDF start lists) so drivers can see roughly when their session begins.",
|
||||
"guide.day_flow_title": "Race day step by step: practice → qualifying → finals",
|
||||
@@ -4858,6 +4861,7 @@ const TRANSLATIONS = {
|
||||
"events.schedule_title": "Schedule",
|
||||
"events.schedule_hint": "Set a start time for the day and each session's planned clock time is worked out automatically from its duration, follow-up, and the gap between sessions. If a session runs long or gets paused, the rest of the schedule shifts forward automatically.",
|
||||
"events.schedule_start_time": "Start time",
|
||||
"events.schedule_day_link": "The start time and gap are the same as First start in Race Day (Today's schedule) and change in both places. The times below are Race Day's - set breaks between rounds, lunch and the heat order there.",
|
||||
"events.schedule_gap": "Gap between sessions (min)",
|
||||
"events.schedule_save": "Save schedule",
|
||||
"events.schedule_clear": "Clear schedule",
|
||||
@@ -7757,6 +7761,8 @@ function renderEventManager(eventId) {
|
||||
ensureRaceParticipantsConfigured,
|
||||
getSessionsForEvent,
|
||||
buildEventSchedule,
|
||||
getDayPlan,
|
||||
saveDayPlan: (plan) => saveDayPlan({ ...getDayPlan(plan.date), ...plan }),
|
||||
getSelectedTeamEditId: () => selectedTeamEditId,
|
||||
setSelectedTeamEditId: (value) => { selectedTeamEditId = value; },
|
||||
getSelectedSessionEditId: () => selectedSessionEditId,
|
||||
|
||||
@@ -55,6 +55,31 @@ export function getRaceDay(raceDays, date) {
|
||||
return (raceDays || []).find((day) => day.date === date) || normalizeRaceDay({ date });
|
||||
}
|
||||
|
||||
// Race Day's first start is the only start time. A race that got one in Race setup before the
|
||||
// two were joined lends it to its day while the day has none of its own.
|
||||
const localDate = (ms) => { const d = new Date(ms); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; };
|
||||
export function withRaceSetupStart(day, events = []) {
|
||||
if (!day || Number(day.startAt) > 0) return day;
|
||||
const legacy = (events || [])
|
||||
.filter((event) => event.date === day.date)
|
||||
.map((event) => Number(event.raceConfig?.scheduleStartAt || 0))
|
||||
.filter((ms) => ms > 0 && localDate(ms) === day.date)
|
||||
.sort((a, b) => a - b)[0];
|
||||
return legacy ? { ...day, startAt: legacy } : day;
|
||||
}
|
||||
|
||||
// One race's part of the day schedule, in the shape Race setup and the printed start lists use.
|
||||
export function eventScheduleFromDayRows(rows, eventId) {
|
||||
return (rows || []).filter((row) => row.session.eventId === eventId).map((row) => ({
|
||||
sessionId: row.session.id,
|
||||
plannedStart: row.start,
|
||||
plannedEnd: row.end,
|
||||
actualStart: Number(row.session.startedAt || 0) || null,
|
||||
actualEnd: row.state === "done" ? Number(row.session.endedAt || 0) || null : null,
|
||||
delayed: row.delayed,
|
||||
}));
|
||||
}
|
||||
|
||||
// Stores a changed plan for its date; returns the new list.
|
||||
export function upsertRaceDay(raceDays, day) {
|
||||
const next = normalizeRaceDay(day);
|
||||
|
||||
@@ -107,6 +107,8 @@ export function renderEventManagerView(context) {
|
||||
reorderList,
|
||||
getEventName,
|
||||
buildEventSchedule,
|
||||
getDayPlan = () => null,
|
||||
saveDayPlan = () => {},
|
||||
} = context;
|
||||
|
||||
const selectedTeamEditId = getSelectedTeamEditId();
|
||||
@@ -180,6 +182,8 @@ export function renderEventManagerView(context) {
|
||||
setSelectedGridSessionId(selectedGridSession.id);
|
||||
}
|
||||
const eventSchedule = event.mode === "race" ? buildEventSchedule(event) : [];
|
||||
// The start time and gap are Today's schedule's (Race Day) for the race's date - one setting.
|
||||
const dayPlan = event.mode === "race" && event.date ? getDayPlan(event.date) : null;
|
||||
|
||||
eventManageArea.innerHTML = renderEventManagerMarkup({
|
||||
event,
|
||||
@@ -187,6 +191,7 @@ export function renderEventManagerView(context) {
|
||||
escapeHtml,
|
||||
sessions,
|
||||
eventSchedule,
|
||||
dayPlan,
|
||||
sessionTypeChoices,
|
||||
sessionTypeHintKey,
|
||||
raceTeams,
|
||||
@@ -676,6 +681,15 @@ export function renderEventManagerView(context) {
|
||||
document.getElementById("scheduleForm")?.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const form = new FormData(e.currentTarget);
|
||||
if (dayPlan) {
|
||||
const time = String(form.get("scheduleStartTime") || "").trim();
|
||||
const startAt = time ? new Date(`${event.date}T${time}`).getTime() : NaN;
|
||||
saveDayPlan({ date: event.date, startAt: Number.isFinite(startAt) ? startAt : null, gapMin: Math.max(0, Number(form.get("scheduleGapMin")) || 0) });
|
||||
updateEvent((item) => ({ ...item, raceConfig: { ...item.raceConfig, scheduleStartAt: null } }));
|
||||
saveState();
|
||||
refreshManager();
|
||||
return;
|
||||
}
|
||||
const startValue = String(form.get("scheduleStartAt") || "").trim();
|
||||
const parsedStart = startValue ? new Date(startValue).getTime() : NaN;
|
||||
const gapMin = Math.max(0, Number(form.get("scheduleGapMin")) || 0);
|
||||
@@ -692,6 +706,7 @@ export function renderEventManagerView(context) {
|
||||
});
|
||||
|
||||
document.getElementById("scheduleClear")?.addEventListener("click", () => {
|
||||
if (dayPlan) saveDayPlan({ date: event.date, startAt: null });
|
||||
updateEvent((item) => ({ ...item, raceConfig: { ...item.raceConfig, scheduleStartAt: null } }));
|
||||
saveState();
|
||||
refreshManager();
|
||||
|
||||
@@ -33,6 +33,7 @@ export function renderEventManagerMarkup(context) {
|
||||
escapeHtml,
|
||||
sessions,
|
||||
eventSchedule,
|
||||
dayPlan = null,
|
||||
sessionTypeChoices,
|
||||
sessionTypeHintKey,
|
||||
raceTeams,
|
||||
@@ -574,13 +575,18 @@ export function renderEventManagerMarkup(context) {
|
||||
<section class="panel mt-16">
|
||||
<div class="panel-header"><h3>${t("events.schedule_title")}</h3></div>
|
||||
<div class="panel-body">
|
||||
<p class="hint">${t("events.schedule_hint")}</p>
|
||||
<p class="hint">${t("events.schedule_hint")}${dayPlan ? ` ${t("events.schedule_day_link")}` : ""}</p>
|
||||
<form id="scheduleForm" class="form-grid cols-3">
|
||||
${dayPlan ? `
|
||||
<label>${t("events.schedule_start_time")} (${escapeHtml(event.date)})<input type="time" name="scheduleStartTime" value="${dayPlan.startAt ? escapeHtml(formatDateTimeLocalValue(dayPlan.startAt).slice(11, 16)) : ""}" /></label>
|
||||
<label>${t("events.schedule_gap")}<input type="number" min="0" step="1" name="scheduleGapMin" value="${Number(dayPlan.gapMin ?? 3)}" /></label>
|
||||
` : `
|
||||
<label>${t("events.schedule_start_time")}<input type="datetime-local" name="scheduleStartAt" value="${event.raceConfig?.scheduleStartAt ? escapeHtml(formatDateTimeLocalValue(event.raceConfig.scheduleStartAt)) : ""}" /></label>
|
||||
<label>${t("events.schedule_gap")}<input type="number" min="0" step="1" name="scheduleGapMin" value="${Number(event.raceConfig?.scheduleGapMin ?? 3)}" /></label>
|
||||
`}
|
||||
<div class="actions">
|
||||
<button class="btn btn-primary" type="submit">${t("events.schedule_save")}</button>
|
||||
${event.raceConfig?.scheduleStartAt ? `<button id="scheduleClear" class="btn btn-danger" type="button">${t("events.schedule_clear")}</button>` : ""}
|
||||
${(dayPlan ? dayPlan.startAt : event.raceConfig?.scheduleStartAt) ? `<button id="scheduleClear" class="btn btn-danger" type="button">${t("events.schedule_clear")}</button>` : ""}
|
||||
</div>
|
||||
</form>
|
||||
${eventSchedule && eventSchedule.length
|
||||
|
||||
Reference in new issue
Block a user