53 lines
1.6 KiB
Vue
53 lines
1.6 KiB
Vue
<script setup>
|
|
import {onMounted, watch} from "vue";
|
|
import {useAircraftsStore} from "stores/Aircrafts";
|
|
import {useRoute, useRouter} from "vue-router";
|
|
import {useQuasar} from "quasar";
|
|
import AircraftDetailSkeleton from "components/aircrafts/AircraftDetailSkeleton.vue";
|
|
import {successObject} from "src/composables/dialog";
|
|
import {loading, aircraft, fetchAircraft} from "src/composables/objects/aircraft";
|
|
import {useAppStore} from "stores/App";
|
|
import FlightsList from "components/flights/FlightsList.vue";
|
|
import AircraftDetailCard from "components/aircrafts/AircraftDetailCard.vue";
|
|
|
|
const $q = useQuasar();
|
|
const $router = useRouter();
|
|
|
|
const aircraftId = parseInt(useRoute().params.id);
|
|
onMounted(() => {
|
|
fetchAircraft(aircraftId);
|
|
})
|
|
|
|
const deleteAircraft = (id) => {
|
|
useAircraftsStore().delete(id).then(() => {
|
|
$router.push({name: "aircrafts"});
|
|
$q.notify(successObject("Letadlo úspěšně odstraněno"));
|
|
});
|
|
}
|
|
|
|
watch(aircraft, (newVal) => {
|
|
useAppStore().setPageTitle(newVal.callSign);
|
|
useAppStore().setBreadcrumbs([
|
|
{label: "Letadla", to: {name: "aircrafts"}},
|
|
{label: newVal.callSign}
|
|
])
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<AircraftDetailSkeleton v-if="loading || !aircraft"/>
|
|
<template v-else>
|
|
<AircraftDetailCard :aircraft="aircraft" @delete="deleteAircraft" />
|
|
|
|
<q-card class="flight-detail-card" flat>
|
|
<h3>Lety</h3>
|
|
<q-banner v-if="aircraft.flights.length === 0" class="bg-light-blue text-white">
|
|
Zatím žádné lety.
|
|
</q-banner>
|
|
<FlightsList :items="aircraft.flights" v-else/>
|
|
</q-card>
|
|
</template>
|
|
|
|
|
|
</template>
|