diff --git a/packages/nc-gui/components/cell/attachment/Modal.vue b/packages/nc-gui/components/cell/attachment/Modal.vue index de9f4eec48..0da4ac38c7 100644 --- a/packages/nc-gui/components/cell/attachment/Modal.vue +++ b/packages/nc-gui/components/cell/attachment/Modal.vue @@ -20,7 +20,7 @@ const { downloadFile, updateModelValue, selectedImage, - selectedImages, + selectedVisibleItems, bulkDownloadFiles, } = useAttachmentCell()! @@ -100,7 +100,7 @@ function onRemoveFileClick(title: any, i: number) {
{{ column?.title }}
-
+
Bulk Download
@@ -122,9 +122,9 @@ function onRemoveFileClick(title: any, i: number) {
diff --git a/packages/nc-gui/components/cell/attachment/utils.ts b/packages/nc-gui/components/cell/attachment/utils.ts index 32dfdc46ff..e2ab9dc080 100644 --- a/packages/nc-gui/components/cell/attachment/utils.ts +++ b/packages/nc-gui/components/cell/attachment/utils.ts @@ -56,9 +56,6 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( /** for image carousel */ const selectedImage = ref() - /** for bulk download */ - const selectedVisibleItems = ref([]) - const { project } = useProject() const { api, isLoading } = useApi() @@ -68,11 +65,10 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( const { t } = useI18n() /** our currently visible items, either the locally stored or the ones from db, depending on isPublic & isForm status */ - const visibleItems = computed(() => { - const items = isPublic.value && isForm.value ? storedFiles.value : attachments.value - selectedVisibleItems.value = Array.from({ length: items.length }, () => false) - return items - }) + const visibleItems = computed(() => (isPublic.value && isForm.value ? storedFiles.value : attachments.value)) + + /** for bulk download */ + const selectedVisibleItems = ref(Array.from({ length: visibleItems.value.length }, () => false)) /** remove a file from our stored attachments (either locally stored or saved ones) */ function removeFile(i: number) { @@ -212,6 +208,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( /** bulk download selected files */ async function bulkDownloadFiles() { await Promise.all(selectedVisibleItems.value.map(async (v, i) => v && (await downloadFile(visibleItems.value[i])))) + selectedVisibleItems.value = Array.from({ length: visibleItems.value.length }, () => false) } /** download a file */