fix(race): never remake qualifying or finals that have already run; clearing them asks first (1.89.36)
This commit is contained in:
1 parent
01abe5b7ae
commit
93c590e5b8
8 files changed
+66
-17
No files matched your search
@@ -805,7 +805,14 @@ export function renderEventManagerView(context) {
|
||||
refreshManager();
|
||||
});
|
||||
|
||||
// Heats that already ran: Generate refuses (it would delete their laps), Clear asks first.
|
||||
const runHeatNames = (type) => getSessionsForEvent(event.id).filter((s) => s.type === type && s.generated
|
||||
&& (s.status !== "ready" || Object.keys(state.resultsBySession[s.id]?.competitors || {}).length)).map((s) => s.name).join(", ");
|
||||
const confirmClearRunHeats = (type) => { const run = runHeatNames(type); return !run || window.confirm(t("events.clear_run_heats_confirm", { names: run })); };
|
||||
|
||||
document.getElementById("generateQualifying")?.addEventListener("click", () => {
|
||||
const run = runHeatNames("qualification");
|
||||
if (run) { alert(t("events.qualifying_already_run", { names: run })); return; }
|
||||
const created = generateQualifyingForRace(event);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -815,6 +822,7 @@ export function renderEventManagerView(context) {
|
||||
});
|
||||
|
||||
document.getElementById("clearGeneratedQualifying")?.addEventListener("click", () => {
|
||||
if (!confirmClearRunHeats("qualification")) return;
|
||||
clearGeneratedQualifying(event.id);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -839,15 +847,9 @@ export function renderEventManagerView(context) {
|
||||
alert(messages.join("\n"));
|
||||
});
|
||||
|
||||
// Finals that already ran lose their laps when the finals are made again - ask first.
|
||||
const confirmDropRunFinals = () => {
|
||||
const run = getSessionsForEvent(event.id).filter((s) => s.type === "final" && s.generated
|
||||
&& (s.status !== "ready" || Object.keys(state.resultsBySession[s.id]?.competitors || {}).length));
|
||||
return !run.length || window.confirm(t("events.finals_regenerate_confirm", { count: run.length, names: run.map((s) => s.name).join(", ") }));
|
||||
};
|
||||
|
||||
document.getElementById("generateFinals")?.addEventListener("click", () => {
|
||||
if (!confirmDropRunFinals()) return;
|
||||
const run = runHeatNames("final");
|
||||
if (run) { alert(t("events.finals_already_run", { names: run })); return; }
|
||||
const created = generateFinalsForRace(event);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -857,7 +859,7 @@ export function renderEventManagerView(context) {
|
||||
});
|
||||
|
||||
document.getElementById("clearGeneratedFinals")?.addEventListener("click", () => {
|
||||
if (!confirmDropRunFinals()) return;
|
||||
if (!confirmClearRunHeats("final")) return;
|
||||
clearGeneratedFinals(event.id);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
|
||||
Reference in new issue
Block a user