Ne uplne otestovany prepis storu
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
import {useAircraftsStore} from "stores/Aircrafts";
|
||||
import {ref} from "vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
|
||||
export const loading = ref(true);
|
||||
|
||||
export const aircraft = ref(null);
|
||||
|
||||
export const fetchAircraft = (aircraftId) => {
|
||||
loading.value = true;
|
||||
return useAircraftsStore().fetchDetail(aircraftId).then((data) => {
|
||||
aircraft.value = data;
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
}).finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
|
||||
export const aircrafts = storeToRefs(useAircraftsStore()).items;
|
||||
export const fetchAircrafts = () => {
|
||||
loading.value = true;
|
||||
useAircraftsStore().fetch().finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
export const isRequestPending = storeToRefs(useAircraftsStore).isMutationRunning;
|
||||
@@ -1,23 +0,0 @@
|
||||
import {ref} from "vue";
|
||||
import {useCopilotsStore} from "stores/Copilots";
|
||||
import {storeToRefs} from "pinia";
|
||||
|
||||
export const loading = ref(true);
|
||||
export const copilot = ref(null);
|
||||
export const fetchCopilot = (copilotId, pilotUsername) => {
|
||||
loading.value = true;
|
||||
return useCopilotsStore().fetchDetail(parseInt(copilotId), pilotUsername)
|
||||
.then(resp => {
|
||||
copilot.value = resp;
|
||||
return resp;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
export const copilots = storeToRefs(useCopilotsStore()).items;
|
||||
export const fetchCopilots = () => {
|
||||
loading.value = true;
|
||||
return useCopilotsStore().fetch().finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
export const isRequestPending = storeToRefs(useCopilotsStore()).isMutationRunning;
|
||||
@@ -1,37 +0,0 @@
|
||||
import {FORMAT_DATE, formatDatetime} from "src/composables/datetimeUtils";
|
||||
import {useEventsStore} from "stores/Events";
|
||||
import {ref} from "vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {confirmObject} from "src/composables/dialog";
|
||||
import {useAppStore} from "stores/App";
|
||||
export const loading = ref(true);
|
||||
export const event = ref(null);
|
||||
export const fetchEvent = (eventId, username) => {
|
||||
loading.value = true;
|
||||
return useEventsStore().fetchDetail(parseInt(eventId), username)
|
||||
.then(respEvent => {
|
||||
event.value = respEvent;
|
||||
return respEvent;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
};
|
||||
|
||||
export const events = storeToRefs(useEventsStore()).items;
|
||||
|
||||
export const fetchEvents = (username) => {
|
||||
loading.value = true;
|
||||
useEventsStore().fetch(username).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const handleDeleteEvent = ($q, eventId, onOkCallback = () => {
|
||||
}) => {
|
||||
$q.dialog(confirmObject(`Opravdu chceš smazat tento let?`))
|
||||
.onOk(() => {
|
||||
useEventsStore().delete(eventId).then(onOkCallback);
|
||||
});
|
||||
};
|
||||
|
||||
export const isRequestPending = storeToRefs(useEventsStore()).isRequestPending;
|
||||
@@ -1,8 +1,4 @@
|
||||
import {FORMAT_DATE, formatDatetime} from "src/composables/datetimeUtils";
|
||||
import {useFlightsStore} from "stores/Flights";
|
||||
import {ref} from "vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {confirmObject} from "src/composables/dialog";
|
||||
|
||||
export const flightName = (flight) => {
|
||||
const date = formatDatetime(flight.takeoffDatetime, FORMAT_DATE);
|
||||
@@ -15,35 +11,3 @@ export const flightName = (flight) => {
|
||||
return `${flight.takeoffAirport.icaoCode} ${trackStr} ${flight.landingAirport.icaoCode} (${date})`;
|
||||
}
|
||||
}
|
||||
|
||||
export const loading = ref(true);
|
||||
export const flight = ref(null);
|
||||
export const fetchFlight = (flightId, username) => {
|
||||
loading.value = true;
|
||||
return useFlightsStore().fetchDetail(parseInt(flightId), username)
|
||||
.then(respFlight => {
|
||||
flight.value = respFlight;
|
||||
return respFlight;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
};
|
||||
|
||||
export const flights = storeToRefs(useFlightsStore()).items;
|
||||
|
||||
export const fetchFlights = (username = null) => {
|
||||
loading.value = true;
|
||||
useFlightsStore().fetch(username).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const handleDeleteFlight = ($q, flightId, onOkCallback = () => {
|
||||
}) => {
|
||||
$q.dialog(confirmObject(`Opravdu chceš smazat tento let?`))
|
||||
.onOk(() => {
|
||||
useFlightsStore().delete(flightId).then(onOkCallback);
|
||||
});
|
||||
};
|
||||
|
||||
export const isRequestPending = storeToRefs(useFlightsStore()).isRequestPending;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import {computed, ref} from "vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {useOrganizationsStore} from "stores/Organizations";
|
||||
import {useUserStore} from "stores/User";
|
||||
import {successObject} from "src/composables/dialog";
|
||||
|
||||
export const loading = ref(true);
|
||||
export const organization = ref(null);
|
||||
export const fetchOrganization = (organizationId) => {
|
||||
loading.value = true;
|
||||
return useOrganizationsStore().fetchDetail(parseInt(organizationId))
|
||||
.then(resp => {
|
||||
organization.value = resp;
|
||||
return resp;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
export const organizations = storeToRefs(useOrganizationsStore()).items;
|
||||
export const fetchOrganizations = () => {
|
||||
loading.value = true;
|
||||
return useOrganizationsStore().fetch().finally(() => loading.value = false);
|
||||
}
|
||||
|
||||
export const isRequestPending = storeToRefs(useOrganizationsStore()).isMutationRunning;
|
||||
|
||||
const loggedUser = storeToRefs(useUserStore()).user;
|
||||
export const myOrganizationIds = computed(() => loggedUser.value.organizations?.map(o => o.id) || []);
|
||||
|
||||
export const addToOrganization = async (organizationId) => {
|
||||
useOrganizationsStore().addUserToOrganization(organizationId).then((data) => {
|
||||
organization.value.users = data.users;
|
||||
useUserStore().fetchLoggedUserDetail();
|
||||
});
|
||||
};
|
||||
|
||||
export const removeFromOrganization = async (organizationId) => {
|
||||
useOrganizationsStore().removeUserFromOrganization(organizationId).then((data) => {
|
||||
organization.value.users = data.users;
|
||||
useUserStore().fetchLoggedUserDetail();
|
||||
});
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import {ref} from "vue";
|
||||
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
||||
import {storeToRefs} from "pinia";
|
||||
|
||||
export const loading = ref(true);
|
||||
export const poi = ref(null);
|
||||
export const fetchPoi = (poiId) => {
|
||||
loading.value = true;
|
||||
return usePointsOfInterestStore().fetchDetail(poiId)
|
||||
.then(data => {
|
||||
poi.value = data;
|
||||
return data;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
};
|
||||
|
||||
|
||||
export const pointsOfInterest = storeToRefs(usePointsOfInterestStore()).items;
|
||||
export const fetchPOIList = () => {
|
||||
loading.value = true;
|
||||
return usePointsOfInterestStore().fetch().finally(() => loading.value = false);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import {ref} from "vue";
|
||||
import {usePhotosStore} from "stores/Photo";
|
||||
import {fetchFlight} from "src/composables/objects/flight";
|
||||
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
||||
|
||||
export const openBatchEdit = ref(false);
|
||||
export const editBatchPhotos = ref([]);
|
||||
export const openBatchPhotoForm = (photos) => {
|
||||
openBatchEdit.value = true;
|
||||
editBatchPhotos.value = photos;
|
||||
}
|
||||
|
||||
export const handleBatchPhotoEdit = async (flightId, data) => {
|
||||
const photoIds = data.photoIds;
|
||||
delete data.photoIds;
|
||||
delete data.id;
|
||||
|
||||
if (data.pointOfInterest && !data.pointOfInterest.id) {
|
||||
const poiData = {
|
||||
...data.pointOfInterest,
|
||||
isPublic: false,
|
||||
description: "",
|
||||
}
|
||||
await usePointsOfInterestStore().create(poiData).then(poi => data.pointOfInterest = {id: poi.id, name: poi.name});
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
for (const id of photoIds) {
|
||||
const updateData = {};
|
||||
if (data.name !== '') updateData.name = data.name;
|
||||
if (data.description !== '') updateData.description = data.description;
|
||||
if (data.pointOfInterest) updateData.pointOfInterest = data.pointOfInterest;
|
||||
|
||||
if (Object.keys(updateData).length === 0) continue;
|
||||
|
||||
promises.push(usePhotosStore().update(id, updateData));
|
||||
}
|
||||
|
||||
Promise.all(promises).finally(() => fetchFlight(flightId))
|
||||
}
|
||||
@@ -1,55 +1,58 @@
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {cropper} from "vue-picture-cropper";
|
||||
import {roundWithPrecision} from "src/composables/utils";
|
||||
import {photoAspectRatio} from "src/composables/photos/editor/photo";
|
||||
|
||||
export const cropperImgSizes = computed(() => [cropper.getImageData().width, cropper.getImageData().height]);
|
||||
export const photoAspectRatio = ref(0);
|
||||
|
||||
export const cropperImgSizes = computed(() => {
|
||||
if (!cropper) return [];
|
||||
|
||||
return [cropper.getImageData().width, cropper.getImageData().height]
|
||||
});
|
||||
export const croppedArea = ref(null);
|
||||
export const selectedAspectRatio = ref(null);
|
||||
|
||||
watch(() => selectedAspectRatio.value, (newVal) => {
|
||||
cropper.setAspectRatio(newVal);
|
||||
console.log(newVal);
|
||||
cropper.setAspectRatio(newVal);
|
||||
})
|
||||
|
||||
|
||||
export const setCropData = () => {
|
||||
const [w, h] = cropperImgSizes.value;
|
||||
const [w, h] = cropperImgSizes.value;
|
||||
|
||||
console.log("crop end");
|
||||
|
||||
const cropData = cropper.getCropBoxData();
|
||||
croppedArea.value = {
|
||||
left: roundWithPrecision(cropData.left / w, 5),
|
||||
top: roundWithPrecision(cropData.top / h, 5),
|
||||
width: roundWithPrecision(cropData.width / w, 5),
|
||||
height: roundWithPrecision(cropData.height / h, 5)
|
||||
};
|
||||
const cropData = cropper.getCropBoxData();
|
||||
croppedArea.value = {
|
||||
left: roundWithPrecision(cropData.left / w, 5),
|
||||
top: roundWithPrecision(cropData.top / h, 5),
|
||||
width: roundWithPrecision(cropData.width / w, 5),
|
||||
height: roundWithPrecision(cropData.height / h, 5)
|
||||
};
|
||||
}
|
||||
|
||||
export const aspectRatioOptions = computed(() =>
|
||||
[
|
||||
{label: '16:9', value: roundWithPrecision(16 / 9, 5)},
|
||||
{label: '4:3', value: roundWithPrecision(4 / 3, 5)},
|
||||
{label: '9:16', value: roundWithPrecision(9 / 16, 5)},
|
||||
{label: '3:4', value: roundWithPrecision(3 / 4, 5)},
|
||||
{label: '1:1', value: 1},
|
||||
{label: 'Volný', value: null},
|
||||
{label: 'Původní', value: roundWithPrecision(photoAspectRatio.value, 5)},
|
||||
]
|
||||
export const aspectRatioOptions = computed(() => [
|
||||
{label: '16:9', value: roundWithPrecision(16 / 9, 5)},
|
||||
{label: '4:3', value: roundWithPrecision(4 / 3, 5)},
|
||||
{label: '9:16', value: roundWithPrecision(9 / 16, 5)},
|
||||
{label: '3:4', value: roundWithPrecision(3 / 4, 5)},
|
||||
{label: '1:1', value: 1},
|
||||
{label: 'Volný', value: null},
|
||||
{label: 'Původní', value: roundWithPrecision(photoAspectRatio.value, 5)},
|
||||
]
|
||||
);
|
||||
|
||||
export const cropperReady = (e) => {
|
||||
if (croppedArea.value) {
|
||||
const [w, h] = cropperImgSizes.value;
|
||||
selectedAspectRatio.value = roundWithPrecision((croppedArea.value.width * w) / (croppedArea.value.height * h), 5);
|
||||
if (croppedArea.value && croppedArea.value.height) {
|
||||
const [w, h] = cropperImgSizes.value;
|
||||
selectedAspectRatio.value = roundWithPrecision((croppedArea.value.width * w) / (croppedArea.value.height * h), 5);
|
||||
|
||||
cropper.setCropBoxData({
|
||||
left: croppedArea.value.left * w,
|
||||
top: croppedArea.value.top * h,
|
||||
width: croppedArea.value.width * w,
|
||||
height: croppedArea.value.height * h
|
||||
});
|
||||
} else {
|
||||
selectedAspectRatio.value = roundWithPrecision(photoAspectRatio.value, 5);
|
||||
}
|
||||
cropper.setCropBoxData({
|
||||
left: croppedArea.value.left * w,
|
||||
top: croppedArea.value.top * h,
|
||||
width: croppedArea.value.width * w,
|
||||
height: croppedArea.value.height * h
|
||||
});
|
||||
} else {
|
||||
selectedAspectRatio.value = roundWithPrecision(photoAspectRatio.value, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import {computed, ref} from "vue";
|
||||
import {usePhotosStore} from "stores/Photo";
|
||||
|
||||
export const loading = ref(true);
|
||||
export const photo = ref(null);
|
||||
export const fetchPhoto = (id) => {
|
||||
loading.value = true;
|
||||
return usePhotosStore().fetchDetail(id)
|
||||
.then(resp => {
|
||||
photo.value = resp;
|
||||
return resp;
|
||||
})
|
||||
.finally(() => loading.value = false);
|
||||
};
|
||||
|
||||
export const photoAspectRatio = computed(() => photo.value.width / photo.value.height);
|
||||
@@ -1,22 +0,0 @@
|
||||
import {usePhotosStore} from "stores/Photo";
|
||||
import {fetchFlight} from "src/composables/objects/flight";
|
||||
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
||||
import {ref} from "vue";
|
||||
|
||||
export const handlePhotoUpdate = (flightId, formData) => {
|
||||
const photoId = formData.id;
|
||||
delete formData.id;
|
||||
|
||||
usePhotosStore().update(photoId, formData).then((data) => {
|
||||
fetchFlight(flightId); // nenacita se mi nove vytvoreny POI z comboboxu
|
||||
usePointsOfInterestStore().fetch();
|
||||
});
|
||||
};
|
||||
|
||||
export const openEdit = ref(false);
|
||||
export const editPhoto = ref(null);
|
||||
|
||||
export const openPhotoEdit = (photo) => {
|
||||
openEdit.value = true;
|
||||
editPhoto.value = photo;
|
||||
};
|
||||
Reference in New Issue
Block a user