Add per-sport location settings and clarify recovery groups
This commit is contained in:
@@ -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']),
|
||||
|
||||
Reference in New Issue
Block a user