Skip to content

Commit 1ff6c21

Browse files
committed
Implement deleted image revert
1 parent 2808742 commit 1ff6c21

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

backend/src/components/ImagePreview.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
<div v-for="image of imageUrls"
44
class="relative w-[120px] h-[120px] rounded border border-dashed flex items-center justify-center hover:border-purple-500 overflow-hidden">
55
<img :src="image.url" class="max-w-full max-h-full" :class="image.deleted ? 'opacity-50' : ''">
6-
<span v-if="image.deleted" class="absolute left-0 bottom-0 right-0 py-1 px-2 bg-black w-100 text-white text-center flex">
6+
<small v-if="image.deleted" class="absolute left-0 bottom-0 right-0 py-1 px-2 bg-black w-100 text-white justify-between items-center flex">
77
To be deleted
8-
</span>
8+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 cursor-pointer" @click="revertImage(image)">
9+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 15L3 9m0 0l6-6M3 9h12a6 6 0 010 12h-3" />
10+
</svg>
11+
</small>
912
<span class="absolute top-1 right-1 cursor-pointer" @click="removeImage(image)">
1013
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
1114
<path
@@ -86,6 +89,15 @@ function removeImage(image) {
8689
}
8790
}
8891
92+
function revertImage(image){
93+
if (image.isProp) {
94+
deletedImages.value = deletedImages.value.filter(id => id !== image.id)
95+
image.deleted = false;
96+
97+
emit('update:deletedImages', deletedImages.value)
98+
}
99+
}
100+
89101
// Hooks
90102
watch('props.images', () => {
91103
console.log(props.images)

0 commit comments

Comments
 (0)