2021-11-30 15:39:08 +00:00
|
|
|
<!--
|
2021-12-17 09:04:49 +00:00
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
|
|
|
//
|
2021-11-30 15:39:08 +00:00
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
2021-12-17 09:04:49 +00:00
|
|
|
//
|
2021-11-30 15:39:08 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2021-12-17 09:04:49 +00:00
|
|
|
//
|
2021-11-30 15:39:08 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2022-01-11 09:07:29 +00:00
|
|
|
import { Class, Doc, Ref, Space } from '@anticrm/core'
|
2022-04-12 17:28:46 +00:00
|
|
|
import { Label, Spinner } from '@anticrm/ui'
|
2022-05-28 07:33:11 +00:00
|
|
|
import view from '@anticrm/view'
|
2021-11-30 15:39:08 +00:00
|
|
|
import { Table } from '@anticrm/view-resources'
|
2022-01-11 09:07:29 +00:00
|
|
|
import attachment from '../plugin'
|
2022-04-12 17:28:46 +00:00
|
|
|
import AddAttachment from './AddAttachment.svelte'
|
|
|
|
import AttachmentDroppable from './AttachmentDroppable.svelte'
|
2021-11-30 15:39:08 +00:00
|
|
|
import UploadDuo from './icons/UploadDuo.svelte'
|
|
|
|
|
|
|
|
export let objectId: Ref<Doc>
|
|
|
|
export let space: Ref<Space>
|
|
|
|
export let _class: Ref<Class<Doc>>
|
2022-04-12 17:28:46 +00:00
|
|
|
|
2022-01-12 09:18:50 +00:00
|
|
|
export let attachments: number | undefined = undefined
|
2021-11-30 15:39:08 +00:00
|
|
|
|
|
|
|
let inputFile: HTMLInputElement
|
|
|
|
let loading = 0
|
|
|
|
let dragover = false
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="attachments-container">
|
|
|
|
<div class="flex-row-center">
|
2022-02-23 16:10:11 +00:00
|
|
|
<span class="title"><Label label={attachment.string.Attachments} /></span>
|
2022-04-13 09:33:22 +00:00
|
|
|
{#if loading}
|
|
|
|
<Spinner />
|
|
|
|
{:else}
|
|
|
|
<AddAttachment bind:loading bind:inputFile objectClass={_class} {objectId} {space} />
|
|
|
|
{/if}
|
2021-11-30 15:39:08 +00:00
|
|
|
</div>
|
2022-04-13 09:33:22 +00:00
|
|
|
|
2022-05-25 05:56:06 +00:00
|
|
|
{#if !loading && (attachments === null || attachments === 0)}
|
2022-04-12 17:28:46 +00:00
|
|
|
<AttachmentDroppable bind:loading bind:dragover objectClass={_class} {objectId} {space}>
|
|
|
|
<div class="flex-col-center mt-5 zone-container" class:solid={dragover}>
|
|
|
|
<UploadDuo size={'large'} />
|
2022-04-13 09:18:44 +00:00
|
|
|
<div class="text-sm content-dark-color mt-2" style:pointer-events="none">
|
2022-04-12 17:28:46 +00:00
|
|
|
<Label label={attachment.string.NoAttachments} />
|
|
|
|
</div>
|
2022-04-13 09:18:44 +00:00
|
|
|
<div class="text-sm" style:pointer-events={dragover ? 'none' : 'all'}>
|
2022-04-12 17:28:46 +00:00
|
|
|
<div class="over-underline" on:click={() => inputFile.click()}>
|
|
|
|
<Label label={attachment.string.UploadDropFilesHere} />
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-30 15:39:08 +00:00
|
|
|
</div>
|
2022-04-12 17:28:46 +00:00
|
|
|
</AttachmentDroppable>
|
2021-11-30 15:39:08 +00:00
|
|
|
{:else}
|
2021-12-02 13:12:16 +00:00
|
|
|
<Table
|
2021-12-06 10:07:08 +00:00
|
|
|
_class={attachment.class.Attachment}
|
2022-05-28 07:33:11 +00:00
|
|
|
config={[
|
|
|
|
'',
|
|
|
|
'description',
|
|
|
|
{
|
|
|
|
key: 'pinned',
|
|
|
|
presenter: view.component.BooleanTruePresenter,
|
|
|
|
label: attachment.string.Pinned,
|
|
|
|
sortingKey: 'pinned'
|
|
|
|
},
|
|
|
|
'lastModified'
|
|
|
|
]}
|
|
|
|
options={{ sort: { pinned: -1 } }}
|
2021-12-02 13:12:16 +00:00
|
|
|
query={{ attachedTo: objectId }}
|
2022-04-23 02:40:38 +00:00
|
|
|
loadingProps={{ length: attachments ?? 0 }}
|
|
|
|
/>
|
2021-11-30 15:39:08 +00:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.attachments-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
.title {
|
2021-12-15 09:15:43 +00:00
|
|
|
margin-right: 0.75rem;
|
2021-11-30 15:39:08 +00:00
|
|
|
font-weight: 500;
|
|
|
|
font-size: 1.25rem;
|
|
|
|
color: var(--theme-caption-color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.zone-container {
|
|
|
|
padding: 1rem;
|
|
|
|
color: var(--theme-caption-color);
|
2021-12-08 09:24:24 +00:00
|
|
|
background: var(--theme-bg-accent-color);
|
|
|
|
border: 1px dashed var(--theme-zone-border-lite);
|
2021-12-15 09:15:43 +00:00
|
|
|
border-radius: 0.75rem;
|
2022-04-12 17:28:46 +00:00
|
|
|
&.solid {
|
|
|
|
border-style: solid;
|
|
|
|
}
|
2021-11-30 15:39:08 +00:00
|
|
|
}
|
2021-12-02 13:12:16 +00:00
|
|
|
</style>
|