Warn when a driver's transponder collides with a different driver
Registering or editing a driver with a transponder already assigned to a different driver (e.g. a wrong-class typo) previously saved silently - the only symptom was that driver's laps never registering during their heat, with no indication why. Now a confirm dialog names the conflicting driver and their class before saving; the same person's own multiple class entries sharing one physical transponder are correctly never flagged. Also confirms two things the user asked to verify: the race clock already counts down for all timed session types (only open practice counts up unbounded), and a driver not entered in a heat already has their laps fully discarded rather than recorded - both were already correct, no changes needed there. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50586e8859
commit
ba2d78779f
9 files changed
+100
-5
No files matched your search
+11
-2
@@ -1,4 +1,4 @@
|
||||
import { getDriverProfileGroups, getDriverProfileId } from "./driver_profile_logic.js";
|
||||
import { getDriverProfileGroups, getDriverProfileId, findTransponderConflict } from "./driver_profile_logic.js";
|
||||
|
||||
function getScheduleDriftSummary(state) {
|
||||
const scheduledSessions = state.sessions
|
||||
@@ -515,13 +515,18 @@ export function renderDriversView(deps) {
|
||||
? uid("profile")
|
||||
: sameNameProfile?.id || uid("profile");
|
||||
const linkedProfile = profileGroups.find((profile) => profile.id === profileId);
|
||||
const cleanedTransponder = String(form.get("transponder") || "").trim();
|
||||
const transponderConflict = findTransponderConflict(state.drivers, { transponder: cleanedTransponder, profileId });
|
||||
if (transponderConflict && !window.confirm(t("drivers.transponder_conflict_confirm", { tp: cleanedTransponder, name: transponderConflict.name, class: getClassName(transponderConflict.classId) }))) {
|
||||
return;
|
||||
}
|
||||
state.drivers.push(
|
||||
normalizeDriver({
|
||||
id: driverId,
|
||||
name: driverName,
|
||||
classId: String(form.get("classId")),
|
||||
brand: String(form.get("brand") || "").trim(),
|
||||
transponder: String(form.get("transponder") || "").trim(),
|
||||
transponder: cleanedTransponder,
|
||||
speechName: String(form.get("speechName") || "").trim(),
|
||||
passSound: String(form.get("passSound") || "").trim(),
|
||||
profileId,
|
||||
@@ -634,6 +639,10 @@ export function renderDriversView(deps) {
|
||||
setFormError("driverEditError", t("validation.invalid_selection"));
|
||||
return;
|
||||
}
|
||||
const transponderConflict = findTransponderConflict(state.drivers, { transponder: cleanedTp, profileId: cleanedProfileId, excludeDriverId: editingDriver.id });
|
||||
if (transponderConflict && !window.confirm(t("drivers.transponder_conflict_confirm", { tp: cleanedTp, name: transponderConflict.name, class: getClassName(transponderConflict.classId) }))) {
|
||||
return;
|
||||
}
|
||||
setFormError("driverEditError", "");
|
||||
state.drivers = state.drivers.map((item) => {
|
||||
if (item.id === editingDriver.id) {
|
||||
|
||||
Reference in new issue
Block a user