Add per-sport location settings and clarify recovery groups

This commit is contained in:
2026-04-12 11:57:13 +02:00
parent 80f649c547
commit 1080dd9d82
8 changed files with 104 additions and 9 deletions
+23
View File
@@ -240,6 +240,23 @@ function sport_icon_options(): array
];
}
function sport_location_options(): array
{
return [
'' => 'ohne Angabe',
'home' => 'Zuhause',
'away' => 'Auswärts',
];
}
function sport_location_label(?string $value): string
{
$options = sport_location_options();
$value = is_string($value) ? trim($value) : '';
return $options[$value] ?? '';
}
function normalize_sport_type_id(string $value): string
{
$value = trim(strtr($value, [
@@ -300,6 +317,11 @@ function normalized_sport_types(array $settings): array
$icon = 'run';
}
$location = trim((string) ($type['location'] ?? ''));
if (!array_key_exists($location, sport_location_options())) {
$location = '';
}
$group = trim((string) ($type['recovery_group'] ?? ''));
if ($group === '') {
$group = $id;
@@ -309,6 +331,7 @@ function normalized_sport_types(array $settings): array
'id' => $id,
'label' => $label,
'icon' => $icon,
'location' => $location,
'recovery_group' => normalize_sport_type_id($group) ?: $id,
'bonus_points' => max(0, min(20, (int) ($type['bonus_points'] ?? 0))),
'allow_consecutive' => !empty($type['allow_consecutive']),