Upravy UI, refaktoring, davkove upravy a mazani fotek
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import {ref} from "vue";
|
||||
import {usePhotosStore} from "stores/Photo";
|
||||
import {fetchFlight} from "src/composables/objects/flight";
|
||||
|
||||
export const openBatchEdit = ref(false);
|
||||
export const editBatchPhotos = ref([]);
|
||||
export const openBatchPhotoForm = (photos) => {
|
||||
openBatchEdit.value = true;
|
||||
editBatchPhotos.value = photos;
|
||||
}
|
||||
|
||||
export const handleBatchPhotoEdit = (flightId, data) => {
|
||||
const photoIds = data.photoIds;
|
||||
delete data.photoIds;
|
||||
delete data.id;
|
||||
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user