feat(practice): open practice settings with ranking by best N in a row or best X minutes (1.68.0)
This commit is contained in:
1 parent
8a8b2417fd
commit
a7d2d0b9ae
11 files changed
+243
-7
No files matched your search
@@ -377,6 +377,23 @@ export function renderEventWorkspaceView(context) {
|
||||
setFormError("eventEditError", t("validation.invalid_selection"));
|
||||
return;
|
||||
}
|
||||
// Open practice: lap window on the event, ranking on its practice session(s).
|
||||
let practiceConfig = {};
|
||||
if (editingEvent.raceConfig?.practiceOnly) {
|
||||
const minLapMs = Math.round(Number(form.get("minLapSec") || 0) * 1000);
|
||||
const maxLapMs = Math.round(Number(form.get("maxLapSec") || 0) * 1000);
|
||||
if (minLapMs > 0 && maxLapMs > 0 && maxLapMs <= minLapMs) {
|
||||
setFormError("eventEditError", t("race_day.lap_window_invalid"));
|
||||
return;
|
||||
}
|
||||
practiceConfig = { minLapMs: Math.max(0, minLapMs), maxLapMs: Math.max(0, maxLapMs) };
|
||||
state.sessions.forEach((session) => {
|
||||
if (session.eventId !== editingEvent.id || !["open_practice", "free_practice"].includes(session.type)) return;
|
||||
session.practiceRanking = String(form.get("practiceRanking") || "best_lap");
|
||||
session.practiceRankLaps = Math.max(2, Math.min(50, Math.round(Number(form.get("practiceRankLaps")) || 3)));
|
||||
session.practiceRankMin = Math.max(1, Math.min(120, Math.round(Number(form.get("practiceRankMin")) || 5)));
|
||||
});
|
||||
}
|
||||
setFormError("eventEditError", "");
|
||||
state.events = state.events.map((item) =>
|
||||
item.id === editingEvent.id
|
||||
@@ -385,6 +402,7 @@ export function renderEventWorkspaceView(context) {
|
||||
name: cleanedName,
|
||||
date: cleanedDate,
|
||||
classId: cleanedClassId || item.classId,
|
||||
...(item.raceConfig?.practiceOnly ? { raceConfig: { ...item.raceConfig, ...practiceConfig } } : {}),
|
||||
})
|
||||
: item
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user