Otaceni fotek

This commit is contained in:
Michal Kváček
2023-09-21 09:39:22 +02:00
parent d1baec342f
commit b64c426179
6 changed files with 85 additions and 21 deletions
@@ -100,6 +100,28 @@ const deletePhoto = (id) => {
flight.value.photos.splice(_findPhotoIndex(data.id), 1);
});
}
const rotatePhotos = ({photos, angle}) => {
const promises = [];
for (const photo of photos) {
promises.push(usePhotosStore().rotate(photo.id, angle));
}
let success = 0;
Promise.allSettled(promises).then(result => {
for (const updatedPhoto of result) {
const {status, value} = updatedPhoto;
if (status === 'fulfilled') success++;
const idx =_findPhotoIndex(value.id);
value.thumbnailUrl += "?t=" + (new Date()).getTime();
flight.value.photos[idx] = value;
}
if (success > 0)
$q.notify(successObject("Otočeno " + success + " fotek"));
});
}
</script>
<template>
@@ -143,6 +165,7 @@ const deletePhoto = (id) => {
:photos="flight.photos"
@edit="openPhotoEdit"
@batch-edit="openBatchPhotoForm"
@batch-rotate="rotatePhotos"
@delete="deletePhoto"
/>