Prusunuti nacitani detailu do prefetche (neverejna cast), zruseni resetu breadcrumbs a title pred zmenou routy

This commit is contained in:
Michal Kváček
2024-03-13 07:31:53 +01:00
parent 48f57cde0d
commit 9379d3bfd6
6 changed files with 61 additions and 46 deletions
+21 -10
View File
@@ -1,9 +1,18 @@
<script>
import {useCopilotsStore} from "stores/Copilots";
export default {
preFetch({currentRoute}) {
return useCopilotsStore().fetchDetail(currentRoute.params.id);
}
}
</script>
<script setup>
import {useRoute} from "vue-router";
import CopilotDetailSkeleton from "components/copilots/skeletons/CopilotDetailSkeleton.vue";
import {useAppStore} from "stores/App";
import FlightsList from "components/flights/FlightsList.vue";
import {useCopilotsStore} from "stores/Copilots";
import {storeToRefs} from "pinia";
import PhotoGallery from "components/photos/PhotoGallery.vue";
import ContentCard from "components/ContentCard.vue";
@@ -15,15 +24,16 @@ import {useLoggedUserStore} from "stores/LoggedUser";
import PublishButton from "components/inputs/PublishButton.vue";
import CopyLinkButton from "components/inputs/CopyLinkButton.vue";
import {toggleVisibility} from "src/composables/form/formHandling";
import {onMounted} from "vue";
const {isQueryRunning, copilot} = storeToRefs(useCopilotsStore());
const copilotId = parseInt(useRoute().params.id);
useCopilotsStore().fetchDetail(copilotId).then(() => {
useAppStore().setPageTitle(copilot.value.name);
useAppStore().setBreadcrumbs([
{to: {name: "copilots"}, label: "Kopiloti"},
{label: copilot.value.name}
])
});
useAppStore().setPageTitle(copilot.value.name);
useAppStore().setBreadcrumbs([
{to: {name: "copilots"}, label: "Kopiloti"},
{label: copilot.value.name}
])
const $q = useQuasar();
const togglePublicVisibility = (variables) => toggleVisibility({
@@ -32,10 +42,11 @@ const togglePublicVisibility = (variables) => toggleVisibility({
const {filters, loadPage, paginationLimit} = usePagination({fetchFunction: useFlightsStore().fetch});
filters.value = {copilotId: copilotId};
loadPage(false);
onMounted(() => {
loadPage(false);
});
const {isQueryRunning: areFlightsLoading, totalItemsCount, flights} = storeToRefs(useFlightsStore());
const {isQueryRunning, copilot} = storeToRefs(useCopilotsStore());
const loggedUser = storeToRefs(useLoggedUserStore()).user;
</script>