Added Crew and General Aviation Filters
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user