Fix attachment dragndrop (#2687)

Signed-off-by: Denis Maslennikov <denis.maslennikov@gmail.com>
This commit is contained in:
Denis Maslennikov 2023-02-27 13:20:18 +07:00 committed by GitHub
parent 8f0f69f144
commit 10a8362de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -13,20 +13,26 @@
// limitations under the License.
-->
<script lang="ts">
import { Class, Doc, Ref, Space } from '@hcengineering/core'
import { Attachment } from '@hcengineering/attachment'
import { Class, Data, Doc, Ref, Space } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { createAttachments } from '../utils'
import attachment from '../plugin'
import { createEventDispatcher } from 'svelte'
export let loading: number = 0
export let objectClass: Ref<Class<Doc>>
export let objectId: Ref<Doc>
export let space: Ref<Space>
export let attachmentClass: Ref<Class<Attachment>> = attachment.class.Attachment
export let attachmentClassOptions: Partial<Data<Attachment>> = {}
export let canDrop: ((e: DragEvent) => boolean) | undefined = undefined
export let dragover = false
const client = getClient()
const dispatch = createEventDispatcher()
async function fileDrop (e: DragEvent) {
dragover = false
@ -43,10 +49,12 @@
loading++
try {
await createAttachments(client, list, { objectClass, objectId, space })
await createAttachments(client, list, { objectClass, objectId, space }, attachmentClass, attachmentClassOptions)
} finally {
loading--
}
dispatch('attached')
}
</script>

View File

@ -72,7 +72,15 @@
</div>
{#if !loading && (attachments === null || attachments === 0) && !readonly}
<AttachmentDroppable bind:loading bind:dragover objectClass={_class} {objectId} {space}>
<AttachmentDroppable
bind:loading
bind:dragover
objectClass={_class}
{objectId}
{space}
{attachmentClass}
{attachmentClassOptions}
>
<div class="antiSection-empty attachments flex-col mt-3" class:solid={dragover}>
<div class="flex-center content-accent-color">
<UploadDuo size={'large'} />