Added Crew and General Aviation Filters

This commit is contained in:
2026-04-20 22:30:34 +10:00
parent e007824fa9
commit a57775e141
26 changed files with 559 additions and 98 deletions
+28 -3
View File
@@ -5,7 +5,7 @@ import { Head, useForm } from '@inertiajs/vue3'
import AirlineSearchBox from '@/Components/FlightsGoneBy/AirlineSearchBox.vue'
import AircraftSearchBox from '@/Components/FlightsGoneBy/AircraftSearchBox.vue'
import AirportSearchBox from '@/Components/FlightsGoneBy/AirportSearchBox.vue'
import type { SeatType, FlightReason, FlightClass} from '@/Types/types'
import type {SeatType, FlightReason, FlightClass, CrewType} from '@/Types/types'
import { ref, watch, computed } from 'vue'
defineOptions({ layout: MainLayout })
@@ -24,6 +24,7 @@ const props = defineProps<{
seat_type: SeatType | null
flight_class: FlightClass | null
flight_reason: FlightReason | null
crew_type: CrewType | null
airline_options: { value: number; title: string }[]
from_options: { value: number; title: string; country_code: string }[]
to_options: { value: number; title: string; country_code: string }[]
@@ -32,6 +33,7 @@ const props = defineProps<{
seat_types: SeatType[]
flight_classes: FlightClass[]
flight_reasons: FlightReason[]
crew_types: CrewType[]
}>()
const isEdit = !!props.flight
@@ -111,10 +113,17 @@ const form = useForm({
seat_type: props.flight?.seat_type ?? props.seat_types[0] ?? null as SeatType | null,
flight_class: props.flight?.flight_class ?? props.flight_classes[0] ?? null as FlightClass | null,
flight_reason: props.flight?.flight_reason ?? props.flight_reasons[0] ?? null as FlightReason | null,
crew_type: props.flight?.crew_type ?? null as CrewType | null,
note: props.flight?.note ?? '',
auto_update: props.flight?.auto_update ?? false,
})
const isCrew = computed(() => form.flight_reason?.name === 'Crew')
watch(isCrew, (val) => {
if (!val) form.crew_type = null
})
// ── Submit form (ID-based, what actually gets sent) ───────────────────────────
const submitForm = useForm({
@@ -130,12 +139,13 @@ const submitForm = useForm({
seat_type_id: null as number | null,
flight_class_id: null as number | null,
flight_reason_id: null as number | null,
crew_type_id: null as number | null,
note: '' as string | null,
auto_update: false,
})
function submit() {
submitForm.flight_number = flightNumber.value
submitForm.flight_number = flightNumber.value
submitForm.departure_date = form.departure_date
submitForm.arrival_date = form.arrival_date
submitForm.from_id = form.from?.value ?? null
@@ -147,6 +157,7 @@ function submit() {
submitForm.seat_type_id = form.seat_type?.id
submitForm.flight_class_id = form.flight_class?.id
submitForm.flight_reason_id = form.flight_reason?.id
submitForm.crew_type_id = form.crew_type?.id ?? null
submitForm.note = form.note
submitForm.auto_update = form.auto_update
@@ -306,6 +317,7 @@ const arrivalMax = computed(() => {
/>
</v-col>
</v-row>
<!-- Registration + Flight class -->
<v-row>
<v-col cols="12" md="6">
@@ -356,7 +368,7 @@ const arrivalMax = computed(() => {
</v-col>
</v-row>
<!-- Flight reason -->
<!-- Flight reason + Crew type -->
<v-row>
<v-col cols="12" md="6">
<v-select
@@ -370,6 +382,18 @@ const arrivalMax = computed(() => {
:error-messages="submitForm.errors.flight_reason_id"
/>
</v-col>
<v-col v-if="isCrew" cols="12" md="6">
<v-select
v-model="form.crew_type"
label="Crew Type"
:items="crew_types"
item-title="name"
item-value="id"
:return-object="true"
:disabled="!lookupComplete"
:error-messages="submitForm.errors.crew_type_id"
/>
</v-col>
</v-row>
<!-- Note -->
@@ -399,6 +423,7 @@ const arrivalMax = computed(() => {
/>
</v-col>
</v-row>
<!-- Submit -->
<v-row>
<v-col cols="12">
+8 -7
View File
@@ -1,10 +1,10 @@
<script setup lang="ts">
import MainLayout from "@/Layouts/MainLayout.vue";
import { Head } from '@inertiajs/vue3'
import {ref, computed, defineAsyncComponent, watchEffect, onMounted} from 'vue'
import {ref, computed, watchEffect} from 'vue'
import { Flight, ProfileView, User } from "@/Types/types"
import { router } from '@inertiajs/vue3'
import { useFlightStats, FlightStats } from "@/Composables/useFlightStats"
import { useFlightStats } from "@/Composables/useFlightStats"
import ProfileViewSwitcher from "@/Components/FlightsGoneBy/ProfileViewSwitcher.vue"
import ProfileLayout from "@/Components/FlightsGoneBy/ProfileLayout.vue"
import DepartureBoard from "@/Components/FlightsGoneBy/DepartureBoard.vue"
@@ -29,6 +29,7 @@ const selectedAirlines = ref<number[]>([])
const selectedCountries = ref<string[]>([])
const selectedContinents = ref<string[]>([])
const selectedFlightClasses = ref<number[]>([])
const selectedCrewTypes = ref<number[]>([])
function onFiltersChange(filters: {
years: number[]
@@ -36,18 +37,17 @@ function onFiltersChange(filters: {
countries: string[]
continents: string[]
flightClasses: number[]
crewTypes: number[]
}) {
localSelectedFlightId.value = null
console.time('filter+stats')
selectedYears.value = filters.years
selectedAirlines.value = filters.airlines
selectedCountries.value = filters.countries
selectedContinents.value = filters.continents
selectedFlightClasses.value = filters.flightClasses
console.timeEnd('filter+stats')
selectedCrewTypes.value = filters.crewTypes
}
function matchesFilters(f: Flight): boolean {
const date = new Date(f.departure_date)
if (selectedYears.value.length && !selectedYears.value.includes(date.getFullYear())) return false
@@ -62,8 +62,10 @@ function matchesFilters(f: Flight): boolean {
const arrCode = f.arrival_airport.region?.continent?.code
if (!selectedContinents.value.includes(depCode ?? '') && !selectedContinents.value.includes(arrCode ?? '')) return false
}
return !(selectedFlightClasses.value.length && !selectedFlightClasses.value.includes(f.flight_class?.id ?? -1));
if (selectedFlightClasses.value.length && !selectedFlightClasses.value.includes(f.flight_class?.id ?? -1)) return false
if (selectedCrewTypes.value.length && !selectedCrewTypes.value.includes(f.crew_type?.id ?? -1)) return false
return true
}
const filteredFlights = computed(() => {
@@ -77,7 +79,6 @@ const stats = useFlightStats(filteredFlights)
watchEffect(() => {
console.time('all.charts.input')
// just access each stat to trigger the log
const _ = [
stats.perYear.value,
stats.perMonth.value,