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
@@ -80,19 +91,20 @@ {:else} { inputFile.click() } } /> {/if} - +
- {#if kl} + {#if attachments.length === 0 && !loading}
{ dragover = true } } on:dragleave={ () => { dragover = false } } - on:drop|preventDefault|stopPropagation + on:drop|preventDefault|stopPropagation={fileDrop} + on:click={ () => { inputFile.click() } } >
There are no attachments for this candidate.
- { inputFile.click() } } /> or drop files here + Upload or drop files here
{:else} @@ -160,6 +172,7 @@ } .resume { + cursor: pointer; padding: 1rem; color: var(--theme-caption-color); background: rgba(255, 255, 255, .03);