diff --git a/plugins/recruit-resources/src/components/Attachments.svelte b/plugins/recruit-resources/src/components/Attachments.svelte index e738750cca..5f9387b2c1 100644 --- a/plugins/recruit-resources/src/components/Attachments.svelte +++ b/plugins/recruit-resources/src/components/Attachments.svelte @@ -38,12 +38,12 @@ $: query.query(chunter.class.Attachment, { attachedTo: objectId }, result => { attachments = result }) let inputFile: HTMLInputElement - let loading = false + let loading = 0 const client = getClient() async function createAttachment(file: File) { - loading = true + loading++ try { const uuid = await uploadFile(space, file, objectId) console.log('uploaded file uuid', uuid) @@ -57,19 +57,30 @@ } catch (err: any) { setPlatformStatus(unknownError(err)) } finally { - loading = false + loading-- } } - function fileSelected() { + function fileSelected () { console.log(inputFile.files) - const file = inputFile.files?.[0] - if (file !== undefined) { createAttachment(file) } + const list = inputFile.files + if (list === null || list.length === 0) return + for (let index = 0; index < list.length; index++) { + const file = list.item(index) + if (file !== null) createAttachment(file) + } + } + + function fileDrop (e: DragEvent) { + const list = e.dataTransfer?.files + if (list === undefined || list.length === 0) return + for (let index = 0; index < list.length; index++) { + const file = list.item(index) + if (file !== null) createAttachment(file) + } } - let kl = true let dragover = false - $: if (loading) kl = false
- {#if kl} + {#if attachments.length === 0 && !loading}