|
|
@ -55,6 +55,8 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const selectedImage = ref() |
|
|
|
const selectedImage = ref() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const selectedImages = ref<boolean[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const { project } = useProject() |
|
|
|
const { project } = useProject() |
|
|
|
|
|
|
|
|
|
|
|
const { api, isLoading } = useApi() |
|
|
|
const { api, isLoading } = useApi() |
|
|
@ -63,6 +65,13 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** our currently visible items, either the locally stored or the ones from db, depending on isPublic & isForm status */ |
|
|
|
|
|
|
|
const visibleItems = computed<any[]>(() => { |
|
|
|
|
|
|
|
const items = isPublic.value && isForm.value ? storedFiles.value : attachments.value |
|
|
|
|
|
|
|
selectedImages.value = Array.from({ length: items.length }, () => false) |
|
|
|
|
|
|
|
return items |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** remove a file from our stored attachments (either locally stored or saved ones) */ |
|
|
|
/** remove a file from our stored attachments (either locally stored or saved ones) */ |
|
|
|
function removeFile(i: number) { |
|
|
|
function removeFile(i: number) { |
|
|
|
if (isPublic.value) { |
|
|
|
if (isPublic.value) { |
|
|
@ -198,6 +207,11 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** bulk download selected files */ |
|
|
|
|
|
|
|
async function bulkDownloadFiles() { |
|
|
|
|
|
|
|
await Promise.all(selectedImages.value.map(async (v, i) => v && (await downloadFile(visibleItems.value[i])))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** download a file */ |
|
|
|
/** download a file */ |
|
|
|
async function downloadFile(item: Record<string, any>) { |
|
|
|
async function downloadFile(item: Record<string, any>) { |
|
|
|
;(await import('file-saver')).saveAs(item.url || item.data, item.title) |
|
|
|
;(await import('file-saver')).saveAs(item.url || item.data, item.title) |
|
|
@ -218,9 +232,6 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** our currently visible items, either the locally stored or the ones from db, depending on isPublic & isForm status */ |
|
|
|
|
|
|
|
const visibleItems = computed<any[]>(() => (isPublic.value && isForm.value ? storedFiles.value : attachments.value)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch(files, (nextFiles) => nextFiles && onFileSelect(nextFiles)) |
|
|
|
watch(files, (nextFiles) => nextFiles && onFileSelect(nextFiles)) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
@ -243,7 +254,9 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( |
|
|
|
downloadFile, |
|
|
|
downloadFile, |
|
|
|
updateModelValue, |
|
|
|
updateModelValue, |
|
|
|
selectedImage, |
|
|
|
selectedImage, |
|
|
|
|
|
|
|
selectedImages, |
|
|
|
storedFiles, |
|
|
|
storedFiles, |
|
|
|
|
|
|
|
bulkDownloadFiles, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
'useAttachmentCell', |
|
|
|
'useAttachmentCell', |
|
|
|