mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
fix attachments
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
48bc68f746
commit
771a0bc91d
@ -16,37 +16,31 @@
|
||||
<script lang="ts">
|
||||
import { ScrollBox, IconAdd } from '@anticrm/ui'
|
||||
|
||||
interface IFile {
|
||||
id: number,
|
||||
name: string,
|
||||
ext: string,
|
||||
description: string
|
||||
}
|
||||
import type { Doc, Ref, Space } from '@anticrm/core'
|
||||
import { createQuery } from '@anticrm/presentation'
|
||||
import type { Attachment } from '@anticrm/chunter'
|
||||
|
||||
import chunter from '@anticrm/chunter'
|
||||
|
||||
export let object: Doc
|
||||
export let space: Ref<Space>
|
||||
|
||||
let files: Attachment[] = []
|
||||
|
||||
console.log('query space', space)
|
||||
|
||||
const query = createQuery()
|
||||
$: query.query(chunter.class.Attachment, { space }, result => { files = result})
|
||||
|
||||
export let files: Array<IFile> = [
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 1, name: 'Application description.pdf', ext: 'pdf', description: 'PDF / 2,5 MB' },
|
||||
{ id: 2, name: 'Location', ext: 'jpg', description: 'JPG / 2,5 MB' },
|
||||
{ id: 3, name: 'Requirements', ext: 'doc', description: 'DOC / 2,5 MB' }
|
||||
]
|
||||
</script>
|
||||
|
||||
<ScrollBox vertical>
|
||||
{#each files as file}
|
||||
<div class="item flex-row-center">
|
||||
<div class="flex-center file-icon">{file.ext}</div>
|
||||
<div class="flex-center file-icon">pdf</div>
|
||||
<div class="flex-col flex-grow">
|
||||
<div class="overflow-label caption-color">{file.name}</div>
|
||||
<div class="overflow-label file-desc">{file.description}</div>
|
||||
<div class="overflow-label file-desc">{file.type}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
@ -37,11 +37,13 @@
|
||||
} as Candidate
|
||||
const newValue = Object.assign({}, object)
|
||||
|
||||
let resumeId: Ref<Doc>
|
||||
let resumeName: string | undefined
|
||||
let resumeUuid: string
|
||||
let resumeSize: number
|
||||
let resumeType: string
|
||||
let resume = {} as {
|
||||
id: Ref<Doc> | undefined
|
||||
name: string
|
||||
uuid: string
|
||||
size: number
|
||||
type: string
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
@ -57,16 +59,19 @@
|
||||
city: newValue.city,
|
||||
})
|
||||
|
||||
if (resumeName !== undefined) {
|
||||
console.log('resume name', resume.name)
|
||||
|
||||
if (resume.id !== undefined) {
|
||||
// create attachment
|
||||
console.log('creaing attachment space', space)
|
||||
client.createDoc(chunter.class.Attachment, space, {
|
||||
attachmentTo: candidateId,
|
||||
collection: 'resume',
|
||||
name: resumeName,
|
||||
file: resumeUuid,
|
||||
type: resumeType,
|
||||
size: resumeSize,
|
||||
}, resumeId)
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
type: resume.type,
|
||||
size: resume.size,
|
||||
}, resume.id)
|
||||
}
|
||||
|
||||
dispatch('close')
|
||||
@ -74,4 +79,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
<DialogHeader {space} {object} {newValue} {resumeId} {resumeName} {resumeUuid} {resumeSize} {resumeType} create={true} on:save={createCandidate}/>
|
||||
<DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/>
|
||||
|
@ -36,11 +36,13 @@
|
||||
export let object: Candidate
|
||||
export let newValue: Candidate
|
||||
|
||||
export let resumeId: Ref<Doc>
|
||||
export let resumeName: string | undefined
|
||||
export let resumeUuid: string
|
||||
export let resumeSize: number
|
||||
export let resumeType: string
|
||||
export let resume: {
|
||||
id: Ref<Doc> | undefined
|
||||
name: string
|
||||
uuid: string
|
||||
size: number
|
||||
type: string
|
||||
}
|
||||
|
||||
export let create = false
|
||||
|
||||
@ -61,13 +63,14 @@
|
||||
async function createAttachment(file: File) {
|
||||
loading = true
|
||||
try {
|
||||
resumeId = generateId()
|
||||
resumeUuid = await uploadFile(resumeId, space, file)
|
||||
resumeName = file.name
|
||||
resumeSize = file.size
|
||||
resumeType = file.type
|
||||
const id = generateId()
|
||||
resume.uuid = await uploadFile(id, space, file)
|
||||
resume.id = id
|
||||
resume.name = file.name
|
||||
resume.size = file.size
|
||||
resume.type = file.type
|
||||
|
||||
console.log('uploaded file uuid', resumeUuid)
|
||||
console.log('uploaded file uuid', resume.uuid)
|
||||
|
||||
} finally {
|
||||
loading = false
|
||||
@ -105,8 +108,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="abs-lb-content">
|
||||
{#if resumeName}
|
||||
<Link label={resumeName} href={'#'} icon={FileIcon} />
|
||||
{#if resume.id}
|
||||
<Link label={resume.name} href={'#'} icon={FileIcon} />
|
||||
{:else}
|
||||
<Button label={'Upload resume'} {loading} icon={FileUpload} size={'small'} transparent primary on:click={() => { inputFile.click() }}/>
|
||||
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected}/>
|
||||
|
@ -28,12 +28,13 @@
|
||||
|
||||
const newValue = Object.assign({}, object)
|
||||
|
||||
let resumeId: Ref<Doc>
|
||||
let resumeName: string | undefined
|
||||
let resumeUuid: string
|
||||
let resumeSize: number
|
||||
let resumeType: string
|
||||
|
||||
let resume = {} as {
|
||||
id: Ref<Doc> | undefined
|
||||
name: string
|
||||
uuid: string
|
||||
size: number
|
||||
type: string
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
@ -80,7 +81,7 @@
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<DialogHeader {space} {object} {newValue} {resumeId} {resumeName} {resumeUuid} {resumeSize} {resumeType} on:save={ save }/>
|
||||
<DialogHeader {space} {object} {newValue} {resume} on:save={ save }/>
|
||||
<div class="tabs-container">
|
||||
<Tabs model={tabModel}/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user