From 41a659b99b1bdaa18cab848bfee0d0d10764b826 Mon Sep 17 00:00:00 2001 From: volar Date: Sun, 3 Dec 2023 02:49:47 +0100 Subject: [PATCH] wip --- .../components/ImageWidgetMultipleInner.vue | 18 ++++++- .../components/ImageWidgetMultipleItem.vue | 11 ++++ .../components/UploadQueueItemEditable.vue | 53 ++++++++++--------- .../uploadQueue/composables/imageStore.ts | 5 ++ .../composables/uploadQueuesStore.ts | 1 + 5 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/components/damImage/uploadQueue/components/ImageWidgetMultipleInner.vue b/src/components/damImage/uploadQueue/components/ImageWidgetMultipleInner.vue index e069989a..1b53ddc4 100644 --- a/src/components/damImage/uploadQueue/components/ImageWidgetMultipleInner.vue +++ b/src/components/damImage/uploadQueue/components/ImageWidgetMultipleInner.vue @@ -8,7 +8,7 @@ import { DamExtSystemConfig } from '@/types/coreDam/DamConfig' import { useImageStore } from '@/components/damImage/uploadQueue/composables/imageStore' import ImageWidgetMultipleItem from '@/components/damImage/uploadQueue/components/ImageWidgetMultipleItem.vue' import { storeToRefs } from 'pinia' -import { bulkUpdateImages, fetchImageListByIds } from '@/components/damImage/uploadQueue/api/imageApi' +import { bulkUpdateImages, deleteImage, fetchImageListByIds } from '@/components/damImage/uploadQueue/api/imageApi' import { useCommonAdminImageOptions } from '@/components/damImage/composables/commonAdminImageOptions' import { useAlerts } from '@/composables/system/alerts' import { DamAssetType } from '@/types/coreDam/Asset' @@ -200,6 +200,21 @@ const saveImages = async () => { } } +const removeItem = async (index: number) => { + const image = images.value[index] + if (!image) return + if (isUndefined(image.id)) { + imageStore.removeImageByIndex(index) + return + } + try { + await deleteImage(imageClient, image.id) + imageStore.removeImageByIndex(index) + } catch (e) { + showErrorsDefault(e) + } +} + defineExpose({ saveImages, }) @@ -252,6 +267,7 @@ onMounted(() => { :key="image.key" :index="index" @edit-asset="onEditAsset" + @remove-item="removeItem" /> () const imageStore = useImageStore() @@ -25,6 +27,10 @@ const onEditAsset = () => { if (isNull(image.value) || isUndefined(image.value)) return emit('editAsset', image.value.dam.damId) } + +const removeItem = () => { + emit('removeItem', props.index) +}