diff --git a/app/Settings/SettingsRegistry.php b/app/Settings/SettingsRegistry.php index 3b354b5..7948662 100644 --- a/app/Settings/SettingsRegistry.php +++ b/app/Settings/SettingsRegistry.php @@ -133,7 +133,7 @@ class SettingsRegistry 'category' => 'FlightsGoneBy Settings', 'type' => 'multiselect', 'label' => 'Which columns to show on the Departure Board', - 'default' => ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'registration', 'class_seat_combined'], + 'default' => ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'aircraft_registration', 'class_seat_combined'], 'options' => [ ['value' => 'airline', 'label' => 'Airline Logo w/ Info Popup'], ['value' => 'airline.name', 'label' => 'Airline Name'], @@ -148,7 +148,7 @@ class SettingsRegistry ['value' => 'duration', 'label' => 'Duration'], ['value' => 'distance', 'label' => 'Distance'], ['value' => 'aircraft', 'label' => 'Aircraft Designator w/ Info Popup'], - ['value' => 'registration', 'label' => 'Aircraft Registration'], + ['value' => 'aircraft_registration', 'label' => 'Aircraft Registration'], ['value' => 'aircraft.manufacturer_code', 'label' => 'Aircraft Manufacturer'], ['value' => 'aircraft.model_full_name', 'label' => 'Aircraft Model'], ['value' => 'flight_class', 'label' => 'Class'], diff --git a/database/migrations/2026_09_15_045243_update_column_settings.php b/database/migrations/2026_09_15_045243_update_column_settings.php new file mode 100644 index 0000000..51096c1 --- /dev/null +++ b/database/migrations/2026_09_15_045243_update_column_settings.php @@ -0,0 +1,65 @@ +renameDepartureBoardColumn('registration', 'aircraft_registration'); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $this->renameDepartureBoardColumn('aircraft_registration', 'registration'); + } + + /** + * Walk every user's settings JSON and rename a value inside + * departure_board_columns, if present. + */ + private function renameDepartureBoardColumn(string $from, string $to): void + { + DB::table('users') + ->select('id', 'settings') + ->whereNotNull('settings') + ->orderBy('id') + ->chunkById(500, function ($users) use ($from, $to) { + foreach ($users as $user) { + $settings = json_decode($user->settings, true); + + // Skip rows with malformed/empty JSON rather than blowing up the migration. + if (! is_array($settings) || ! isset($settings['departure_board_columns'])) { + continue; + } + + if (! is_array($settings['departure_board_columns'])) { + continue; + } + + $columns = $settings['departure_board_columns']; + $key = array_search($from, $columns, true); + + if ($key === false) { + continue; // nothing to change for this user + } + + $columns[$key] = $to; + $settings['departure_board_columns'] = $columns; + + DB::table('users') + ->where('id', $user->id) + ->update([ + 'settings' => json_encode($settings), + ]); + } + }); + } +}; diff --git a/resources/js/Components/FlightsGoneBy/AchievementCard.vue b/resources/js/Components/FlightsGoneBy/AchievementCard.vue index 2339962..0705cbb 100644 --- a/resources/js/Components/FlightsGoneBy/AchievementCard.vue +++ b/resources/js/Components/FlightsGoneBy/AchievementCard.vue @@ -9,8 +9,6 @@ import ButtonLink from "@/Components/FlightsGoneBy/ButtonLink.vue"; import Distance from "@/Components/Distance.vue"; import FormattedNumber from "@/Components/FormattedNumber.vue"; -const distanceAchievementCategoryId = 6 - const props = defineProps<{ achievement: Achievement userAchievement?: UserAchievement @@ -18,6 +16,20 @@ const props = defineProps<{ distanceUnit? : "mi" | "km" | "nm" }>() +const dynamicDistanceUnit = computed(() => { + if(props.achievement.internal_name == 'distance.million_miles'){ + return 'mi' + } + + if(props.achievement.internal_name == 'distance.million_kilometers'){ + return 'km' + } + + return props.distanceUnit ?? 'km'; +}) + + + const progress = computed(() => { if (!props.achievement.progressive || !props.achievement.threshold) return null const current = props.userAchievement?.progress ?? 0 @@ -88,9 +100,9 @@ const unlocked = computed(() => {