Add per-sport location settings and clarify recovery groups
This commit is contained in:
+7
-1
@@ -330,6 +330,7 @@ final class App
|
||||
'authUser' => $user,
|
||||
'settings' => $settings,
|
||||
'sportTypePresets' => $sportTypePresets,
|
||||
'sportLocationOptions' => sport_location_options(),
|
||||
'users' => $user['is_admin'] ? $this->users->all() : [],
|
||||
'maxScore' => $this->scoring->evaluate([
|
||||
'mood' => 10,
|
||||
@@ -481,7 +482,12 @@ final class App
|
||||
'sport' => $entry['sport_minutes'],
|
||||
'walk' => $entry['walk_minutes'],
|
||||
'sport_labels' => array_values(array_filter(array_map(
|
||||
static fn (array $type): string => (string) ($type['label'] ?? ''),
|
||||
static function (array $type): string {
|
||||
$label = (string) ($type['label'] ?? '');
|
||||
$location = sport_location_label((string) ($type['location'] ?? ''));
|
||||
|
||||
return $location !== '' ? $label . ' · ' . $location : $label;
|
||||
},
|
||||
$entry['sport_type_meta'] ?? []
|
||||
))),
|
||||
'sport_icons' => array_values(array_filter(array_map(
|
||||
|
||||
@@ -21,6 +21,7 @@ final class Defaults
|
||||
'id' => 'running',
|
||||
'label' => 'Joggen',
|
||||
'icon' => 'run',
|
||||
'location' => '',
|
||||
'recovery_group' => 'joggen',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -29,6 +30,7 @@ final class Defaults
|
||||
'id' => 'cycling',
|
||||
'label' => 'Radfahren',
|
||||
'icon' => 'bike',
|
||||
'location' => '',
|
||||
'recovery_group' => 'radfahren',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -37,6 +39,7 @@ final class Defaults
|
||||
'id' => 'strength',
|
||||
'label' => 'Krafttraining',
|
||||
'icon' => 'strength',
|
||||
'location' => '',
|
||||
'recovery_group' => 'kraftsport',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -45,6 +48,7 @@ final class Defaults
|
||||
'id' => 'hiking',
|
||||
'label' => 'Wandern',
|
||||
'icon' => 'hike',
|
||||
'location' => '',
|
||||
'recovery_group' => 'wandern',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -53,6 +57,7 @@ final class Defaults
|
||||
'id' => 'swimming',
|
||||
'label' => 'Schwimmen',
|
||||
'icon' => 'swim',
|
||||
'location' => '',
|
||||
'recovery_group' => 'schwimmen',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -61,6 +66,7 @@ final class Defaults
|
||||
'id' => 'yoga',
|
||||
'label' => 'Yoga',
|
||||
'icon' => 'yoga',
|
||||
'location' => '',
|
||||
'recovery_group' => 'yoga',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -69,6 +75,7 @@ final class Defaults
|
||||
'id' => 'hiit-workout',
|
||||
'label' => 'HIIT / Workout',
|
||||
'icon' => 'hiit',
|
||||
'location' => '',
|
||||
'recovery_group' => 'hiit',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -77,6 +84,7 @@ final class Defaults
|
||||
'id' => 'rowing',
|
||||
'label' => 'Rudern',
|
||||
'icon' => 'row',
|
||||
'location' => '',
|
||||
'recovery_group' => 'rudern',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -85,6 +93,7 @@ final class Defaults
|
||||
'id' => 'dance',
|
||||
'label' => 'Tanzen',
|
||||
'icon' => 'dance',
|
||||
'location' => '',
|
||||
'recovery_group' => 'tanzen',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => false,
|
||||
@@ -93,6 +102,7 @@ final class Defaults
|
||||
'id' => 'core',
|
||||
'label' => 'Core',
|
||||
'icon' => 'core',
|
||||
'location' => '',
|
||||
'recovery_group' => 'core',
|
||||
'bonus_points' => 2,
|
||||
'allow_consecutive' => true,
|
||||
|
||||
@@ -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