fix(race): never remake qualifying or finals that have already run; clearing them asks first (1.89.36)

This commit is contained in:
larssand committed 2026-11-15 16:16:28 +01:00
1 parent 01abe5b7ae
commit 93c590e5b8
8 files changed
+66 -17

No files matched your search

+13 -3
View File
@@ -32,7 +32,7 @@ import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudio
import { renderRaceFormatField, renderRaceFormatContextCard, getRaceSummaryItems, getRaceSummaryWarnings, renderManageStatusBadge, renderRaceWizardSteps, renderRaceWizardContent, renderRaceStandingsTable } from "./race_setup_ui.js";
import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, applyBumpsForRace as applyBumpsForRaceLogic, orderSessionsForRunning, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder, planSeedingGroups } from "./event_race_logic.js";
import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, getRunGeneratedSessions, applyBumpsForRace as applyBumpsForRaceLogic, orderSessionsForRunning, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder, planSeedingGroups } from "./event_race_logic.js";
import { getFinishWait as getFinishWaitLogic, getSessionTypeLabel as getSessionTypeLabelLogic, getStatusLabel as getStatusLabelLogic, isUntimedSession as isUntimedSessionLogic, getActiveSession as getActiveSessionLogic, getLiveSession as getLiveSessionLogic, getSessionTargetMs as getSessionTargetMsLogic, getSessionLapWindow as getSessionLapWindowLogic, isCountedPassing as isCountedPassingLogic, getVisiblePassings as getVisiblePassingsLogic, getPassingValidationLabel as getPassingValidationLabelLogic, getSessionTiming as getSessionTimingLogic, ensureSessionResult as ensureSessionResultLogic, buildLeaderboard as buildLeaderboardLogic, formatLapDelta as formatLapDeltaLogic, formatLeaderboardGap as formatLeaderboardGapLogic, getCompetitorElapsedMs as getCompetitorElapsedMsLogic, getCompetitorPassings as getCompetitorPassingsLogic, getCompetitorSeedMetric as getCompetitorSeedMetricLogic, getSessionEntrants as getSessionEntrantsLogic, buildPracticeStandings as buildPracticeStandingsLogic, getQualifyingPointsValue as getQualifyingPointsValueLogic, isHighPointsTable as isHighPointsTableLogic, compareNumberSet as compareNumberSetLogic, buildQualifyingTieBreakNote as buildQualifyingTieBreakNoteLogic, hasQualifyingPrimaryTie as hasQualifyingPrimaryTieLogic, buildQualifyingStandings as buildQualifyingStandingsLogic, formatTeamActiveMemberLabel as formatTeamActiveMemberLabelLogic, buildTeamRaceStandings as buildTeamRaceStandingsLogic, buildSessionChannelStats as buildSessionChannelStatsLogic, buildTeamStintLog as buildTeamStintLogLogic, getSessionGridEntries as getSessionGridEntriesLogic, getSessionGridOrder as getSessionGridOrderLogic, ensureSessionDriverOrder as ensureSessionDriverOrderLogic, buildFinalStandings as buildFinalStandingsLogic, getTrackRecordMs as getTrackRecordMsLogic } from "./timing_logic.js";
import { normalizeTrackLayouts, getTrackLayoutIdAt, getTrackLayoutLabel, nextTrackLayoutLabel, findRaceSessionBlockingLayoutChange, isPracticeSessionType, isTrackLayoutInUse } from "./track_layouts_logic.js";
@@ -111,6 +111,8 @@ const parseQualifyingHeatName = (name) => parseQualifyingHeatNameLogic(name);
const findEventTeamForPassing = (event, driverId, carId) => findEventTeamForPassingLogic(event, driverId, carId, { getEventTeams });
const generateQualifyingForRace = (event) => generateQualifyingForRaceLogic(event, { buildPracticeStandings, getEventDrivers, state, normalizeStartMode, normalizeSession, uid, chunkArray, clearGeneratedQualifying });
const reseedUpcomingQualifying = (event) => reseedUpcomingQualifyingLogic(event, { buildQualifyingStandings, buildPracticeStandings, getEventDrivers, getSessionsForEvent, chunkArray });
// Names of the generated heats of a race that already ran ("" = none): then they can't be made again.
const runGeneratedHeatNames = (eventId, type) => getRunGeneratedSessions(state.sessions, eventId, type, state.resultsBySession).map((session) => session.name).join(", ");
const generateFinalsForRace = (event) => generateFinalsForRaceLogic(event, { buildPracticeStandings, buildQualifyingStandings, clearGeneratedFinals, state, normalizeStartMode, normalizeSession, uid, chunkArray, t });
const applyBumpsForRace = (event) => applyBumpsForRaceLogic(event, { buildFinalStandings, getSessionsForEvent });
@@ -1119,6 +1121,8 @@ const addDriverToSeriesRound = (series, eventId, { name, transponder }) => {
const generateSeriesRoundQualifying = (eventId) => {
const event = findSeriesEvent(eventId);
if (!event) return 0;
const run = runGeneratedHeatNames(eventId, "qualification");
if (run) { window.alert(t("events.qualifying_already_run", { names: run })); return -1; }
const created = generateQualifyingForRace(event);
saveState();
return created;
@@ -1126,6 +1130,8 @@ const generateSeriesRoundQualifying = (eventId) => {
const generateSeriesRoundFinals = (eventId) => {
const event = findSeriesEvent(eventId);
if (!event) return 0;
const run = runGeneratedHeatNames(eventId, "final");
if (run) { window.alert(t("events.finals_already_run", { names: run })); return 0; }
const created = generateFinalsForRace(event);
saveState();
return created;
@@ -2609,7 +2615,9 @@ const TRANSLATIONS = {
"events.final_standings": "Final-ranking",
"events.generated_qualifying": "Kvalheat skapade från ranking.",
"events.finals_generated": "Finaler skapade från ranking.",
"events.finals_regenerate_confirm": "{count} finaler har redan körts ({names}). Deras varv och resultat raderas om finalerna görs om. Fortsätta?",
"events.finals_already_run": "Finalerna har redan börjat köras ({names}), så de görs inte om – då skulle varv och resultat raderas. Vill ni verkligen göra om dem: tryck först \"Rensa genererade finaler\".",
"events.qualifying_already_run": "Kvalet har redan börjat köras ({names}), så det görs inte om – då skulle varv och resultat raderas. Vill ni verkligen göra om det: tryck först \"Rensa genererade kval\".",
"events.clear_run_heats_confirm": "{names} har redan körts. Alla deras varv och resultat raderas och går inte att få tillbaka. Rensa ändå?",
"events.bumps_applied": "Bump-ups applicerade till nästa final.",
"events.no_bumps_applied": "Inga bump-ups kunde appliceras ännu.",
"events.no_practice_results": "Inga practice-resultat ännu.",
@@ -4988,7 +4996,9 @@ const TRANSLATIONS = {
"events.final_standings": "Final standings",
"events.generated_qualifying": "Qualifying heats generated from standings.",
"events.finals_generated": "Finals generated from standings.",
"events.finals_regenerate_confirm": "{count} finals have already run ({names}). Their laps and results are deleted if the finals are made again. Continue?",
"events.finals_already_run": "The finals have already started running ({names}), so they are not made again - that would delete their laps and results. To really redo them, press \"Clear generated finals\" first.",
"events.qualifying_already_run": "Qualifying has already started running ({names}), so it is not made again - that would delete its laps and results. To really redo it, press \"Clear generated qualifying\" first.",
"events.clear_run_heats_confirm": "{names} have already run. All their laps and results are deleted and cannot be brought back. Clear anyway?",
"events.bumps_applied": "Bump-ups applied to the next main.",
"events.no_bumps_applied": "No bump-ups could be applied yet.",
"events.no_practice_results": "No practice results yet.",