fix: better subgroup

This commit is contained in:
2026-06-29 17:35:48 +02:00
parent 9795a4c813
commit 12aada4986
+15 -4
View File
@@ -475,6 +475,17 @@
subgroupSelect.innerHTML = '<option value="">Tous</option>';
}
function extractSubgroup(name) {
// Extract subgroup from name by removing opponent part after " - "
if (!name) return "";
const parts = name.split(" - ");
if (parts.length > 1) {
parts.pop(); // Remove opponent
return parts.join(" - ");
}
return name;
}
function updateSubgroupOptions(selectedAgegroup, events) {
// Reset subgroup options
subgroupSelect.innerHTML = '<option value="">Tous</option>';
@@ -493,10 +504,9 @@
events
.filter(event => event.agegroup === selectedAgegroup)
.forEach(event => {
// Extract subgroup from event.name or event.title
// This assumes the subgroup is part of the name field
// Extract subgroup from event.name by removing opponent
if (event.name && event.name !== selectedAgegroup) {
subgroups.add(event.name);
subgroups.add(extractSubgroup(event.name));
}
});
@@ -521,7 +531,8 @@
if (selectedAgegroup !== "" && event.agegroup !== selectedAgegroup) return false;
// Filter by subgroup
if (selectedSubgroup !== "" && event.name !== selectedSubgroup) return false;
let eventSubgroup = extractSubgroup(event.name);
if (selectedSubgroup !== "" && eventSubgroup !== selectedSubgroup) return false;
return true;
});