46 lines
1.4 KiB
Vue
46 lines
1.4 KiB
Vue
<script>
|
|
import {useFlightsStore} from "stores/Flights";
|
|
|
|
export default {
|
|
preFetch({currentRoute}) {
|
|
const flightId = currentRoute.params.id
|
|
return useFlightsStore().fetchDetail(flightId);
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<script setup>
|
|
import FlightFormSteps from "components/flights/form/FlightFormSteps.vue";
|
|
import {useRoute} from "vue-router";
|
|
import {useQuasar} from "quasar";
|
|
import {storeToRefs} from "pinia";
|
|
import {successObject} from "src/composables/dialog";
|
|
import {flightName} from "src/composables/flight";
|
|
import {useAppStore} from "stores/App";
|
|
|
|
const {flight, isQueryRunning, isRequestPending: isMutationRunning} = storeToRefs(useFlightsStore());
|
|
|
|
const flightNameFormatted = flightName(flight.value);
|
|
useAppStore().setPageTitle(`Editace - ${flightNameFormatted}`);
|
|
useAppStore().setBreadcrumbs([
|
|
{to: {name: "myFlights"}, label: "Moje lety"},
|
|
{to: {name: "flightDetail", params: {id: flight.id}}, label: flightNameFormatted},
|
|
{label: "Editace"}
|
|
]);
|
|
|
|
const $q = useQuasar();
|
|
const $route = useRoute();
|
|
const handleFlightEdit = (data) => {
|
|
const flightId = parseInt($route.params.id);
|
|
useFlightsStore().update(flightId, data).then((data) => {
|
|
$q.notify(successObject("Úspěšně upraveno"));
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<FlightFormSteps :router-edit-mode="true" :flightId="flight.id"/>
|
|
|
|
<router-view :flight="flight" @save="handleFlightEdit"/>
|
|
</template>
|