mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-06 07:46:32 +00:00
Fix attachment dragndrop (#2687)
Signed-off-by: Denis Maslennikov <denis.maslennikov@gmail.com>
This commit is contained in:
parent
8f0f69f144
commit
10a8362de0
@ -13,20 +13,26 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<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 { getClient } from '@hcengineering/presentation'
|
||||||
import { createAttachments } from '../utils'
|
import { createAttachments } from '../utils'
|
||||||
|
import attachment from '../plugin'
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
|
||||||
export let loading: number = 0
|
export let loading: number = 0
|
||||||
export let objectClass: Ref<Class<Doc>>
|
export let objectClass: Ref<Class<Doc>>
|
||||||
export let objectId: Ref<Doc>
|
export let objectId: Ref<Doc>
|
||||||
export let space: Ref<Space>
|
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 canDrop: ((e: DragEvent) => boolean) | undefined = undefined
|
||||||
|
|
||||||
export let dragover = false
|
export let dragover = false
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
async function fileDrop (e: DragEvent) {
|
async function fileDrop (e: DragEvent) {
|
||||||
dragover = false
|
dragover = false
|
||||||
@ -43,10 +49,12 @@
|
|||||||
|
|
||||||
loading++
|
loading++
|
||||||
try {
|
try {
|
||||||
await createAttachments(client, list, { objectClass, objectId, space })
|
await createAttachments(client, list, { objectClass, objectId, space }, attachmentClass, attachmentClassOptions)
|
||||||
} finally {
|
} finally {
|
||||||
loading--
|
loading--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch('attached')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -72,7 +72,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if !loading && (attachments === null || attachments === 0) && !readonly}
|
{#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="antiSection-empty attachments flex-col mt-3" class:solid={dragover}>
|
||||||
<div class="flex-center content-accent-color">
|
<div class="flex-center content-accent-color">
|
||||||
<UploadDuo size={'large'} />
|
<UploadDuo size={'large'} />
|
||||||
|
Loading…
Reference in New Issue
Block a user