From aae5a31f46f75fdafc317ba05e6319b56d162648 Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Thu, 18 May 2023 19:22:38 -0700 Subject: [PATCH] UBER-144: fixed showHeader (#3214) --- .../src/components/Attachments.svelte | 86 +++++++++++++------ 1 file changed, 59 insertions(+), 27 deletions(-) diff --git a/plugins/attachment-resources/src/components/Attachments.svelte b/plugins/attachment-resources/src/components/Attachments.svelte index 3670bfa50c..d7da3c3bc0 100644 --- a/plugins/attachment-resources/src/components/Attachments.svelte +++ b/plugins/attachment-resources/src/components/Attachments.svelte @@ -17,11 +17,13 @@ import { Attachment } from '@hcengineering/attachment' import { Class, Data, Doc, DocumentQuery, Ref, Space } from '@hcengineering/core' import { IntlString } from '@hcengineering/platform' - import { Icon, Label, resizeObserver, Scroller, Spinner } from '@hcengineering/ui' + import { Icon, Label, resizeObserver, Scroller, Spinner, Button, IconAdd } from '@hcengineering/ui' import view, { BuildModelKey } from '@hcengineering/view' import { Table } from '@hcengineering/view-resources' + import { getClient } from '@hcengineering/presentation' import attachment from '../plugin' - import AddAttachment from './AddAttachment.svelte' + import { createAttachments } from '../utils' + import { createEventDispatcher } from 'svelte' import AttachmentDroppable from './AttachmentDroppable.svelte' import IconAttachments from './icons/Attachments.svelte' import UploadDuo from './icons/UploadDuo.svelte' @@ -42,37 +44,67 @@ let loading = 0 let dragover = false let wSection: number + + const client = getClient() + const dispatch = createEventDispatcher() + + async function fileSelected () { + const list = inputFile.files + if (list === null || list.length === 0) return + + loading++ + try { + await createAttachments( + client, + list, + { objectClass: _class, objectId, space }, + attachmentClass, + attachmentClassOptions + ) + } finally { + loading-- + } + + if (inputFile) { + inputFile.value = '' + } + + dispatch('attached') + } + + function openFile () { + inputFile.click() + }
(wSection = element.clientWidth)}> -
-
- {#if showHeader} + {#if showHeader} +
+
- {/if} -
- - {#if showHeader} +
+ -
- {#if loading} - - {:else if !readonly} - - {/if} + +
+ {#if loading} + + {:else if !readonly} +
-
+ {/if} + {#if !loading && (attachments === null || attachments === 0) && !readonly} -
+