Moznost nahravat fotky copilotem

This commit is contained in:
Michal Kváček
2024-03-07 06:45:22 +01:00
parent f0a4c439dc
commit cd9c7351e9
22 changed files with 550 additions and 216 deletions
@@ -3,7 +3,7 @@ import {useCopilotsStore} from "stores/Copilots";
export default {
preFetch({currentRoute}) {
return useCopilotsStore().fetchPublicDetail(currentRoute.params.copilotSlug, currentRoute.params.username);
return useCopilotsStore().fetchPublicDetail({urlSlug: currentRoute.params.copilotSlug, username: currentRoute.params.username});
}
}
</script>
@@ -0,0 +1,100 @@
<script>
import {useCopilotsStore} from "stores/Copilots";
import {useFlightsStore} from "stores/Flights";
export default {
preFetch({currentRoute}) {
return Promise.allSettled([
useFlightsStore().fetchPublicDetail({
username: currentRoute.params.username,
urlSlug: currentRoute.params.flightSlug
}),
useCopilotsStore().fetchPublicDetail({
username: currentRoute.params.username,
uploadToken: currentRoute.query.token,
uploadFlightSlug: currentRoute.params.flightSlug
})
]);
}
}
</script>
<script setup>
import {storeToRefs} from "pinia";
import ContentCard from "components/ContentCard.vue";
import {useAppStore} from "stores/App";
import {useMeta, useQuasar} from "quasar";
import {metaData} from "src/composables/meta";
import {flightName} from "src/composables/flight";
import {usePhotosStore} from "stores/Photos";
import {onMounted, ref} from "vue";
import PhotosEditorListSimple from "components/photos/PhotosEditorListSimple.vue";
import {copilotBreadcrumbs} from "src/composables/breadcrumbs";
import FlightFormPhotos from "components/flights/form/FlightFormPhotos.vue";
import BasicInfoBanner from "components/banners/BasicInfoBanner.vue";
import {useRoute} from "vue-router";
import {useBasicPhotoOperations} from "src/composables/photos/basicOperations";
const props = defineProps({
pilot: {
type: Object,
required: false
},
});
const {copilot} = storeToRefs(useCopilotsStore());
const {flight} = storeToRefs(useFlightsStore());
const {photos, isQueryRunning: arePhotosLoading} = storeToRefs(usePhotosStore())
useAppStore().setPageTitle(`Nahraj fotky - ${props.pilot.name} - ${flightName(flight.value)}`);
useAppStore().setBreadcrumbs([
...copilotBreadcrumbs(props.pilot, flight.value, flight.value.event, copilot.value),
{label: "Nahraj fotky"},
]);
useMeta(() => metaData({
title: `Nahraj fotky: ${copilot.value.name}`,
index: false,
image: copilot.value.titleImage?.url
}));
onMounted(() => {
usePhotosStore().fetchPublic({
flightId: flight.value.id,
uploadedByCopilotId: copilot.value.id
});
});
const $route = useRoute();
const copilotUploadToken = $route.query.token;
const {
uploadInProgress, handlePhotosUpload, batchRotatePhotos, deletePhoto
} = useBasicPhotoOperations({copilotUploadToken});
</script>
<template>
<ContentCard :title="copilot.name">
<template #content>
<q-card-section>
Nahraj fotky k letu {{ flightName(flight) }}
<FlightFormPhotos
:is-request-pending="uploadInProgress"
:flight="flight"
@save="handlePhotosUpload"
/>
<BasicInfoBanner v-if="photos.length === 0 && !arePhotosLoading">
Zatím tu od tebe nejsou nahrané žádné fotky.
</BasicInfoBanner>
<PhotosEditorListSimple
v-else
style="margin-bottom: 150px"
:photos="photos"
@batch-rotate="batchRotatePhotos"
@delete="deletePhoto"
/>
</q-card-section>
</template>
</ContentCard>
</template>
@@ -81,7 +81,7 @@ useMeta(() => metaData({
:flight="flight"
:poi-detail-route="{name: 'publicPOIDetail'}"
:aircraft-detail-route="{name: 'publicAircraftDetail'}"
:event-detail-route="event.isPublic ? {name: 'publicEventDetail', params: {username: pilot.publicUsername, eventSlug: event.urlSlug}} : null"
:event-detail-route="event && event.isPublic ? {name: 'publicEventDetail', params: {username: pilot.publicUsername, eventSlug: event.urlSlug}} : null"
:copilot-detail-route="{name: 'publicCopilotDetail', params: {username: pilot.publicUsername}}"
/>