mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 16:30:49 +00:00
update DialogHeader
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
62b3dbec86
commit
b514235ad0
@ -15,6 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { getMetadata } from '@anticrm/platform'
|
import { getMetadata } from '@anticrm/platform'
|
||||||
import type { Ref, Space, Doc } from '@anticrm/core'
|
import type { Ref, Space, Doc } from '@anticrm/core'
|
||||||
import { generateId } from '@anticrm/core'
|
import { generateId } from '@anticrm/core'
|
||||||
@ -33,12 +34,20 @@
|
|||||||
|
|
||||||
import { uploadFile } from '../utils'
|
import { uploadFile } from '../utils'
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let space: Ref<Space>
|
export let space: Ref<Space>
|
||||||
|
|
||||||
let firstName = ''
|
let firstName = ''
|
||||||
let lastName = ''
|
let lastName = ''
|
||||||
let city = ''
|
let city = ''
|
||||||
|
|
||||||
|
let resumeId: Ref<Doc>
|
||||||
|
let resumeName: string | undefined
|
||||||
|
let resumeUuid: string
|
||||||
|
let resumeSize: number
|
||||||
|
let resumeType: string
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
let dragover = false
|
let dragover = false
|
||||||
@ -47,30 +56,40 @@
|
|||||||
async function createAttachment(file: File) {
|
async function createAttachment(file: File) {
|
||||||
loading = true
|
loading = true
|
||||||
try {
|
try {
|
||||||
const id = generateId()
|
resumeId = generateId()
|
||||||
const uuid = await uploadFile(id, file)
|
resumeUuid = await uploadFile(resumeId, file)
|
||||||
console.log('uploaded file uuid', uuid)
|
resumeName = file.name
|
||||||
|
resumeSize = file.size
|
||||||
|
resumeType = file.type
|
||||||
|
|
||||||
// create candidate
|
console.log('uploaded file uuid', resumeUuid)
|
||||||
const candidateId = generateId()
|
|
||||||
client.createDoc(recruit.class.Candidate, space, {
|
|
||||||
firstName,
|
|
||||||
lastName,
|
|
||||||
email: '',
|
|
||||||
phone: '',
|
|
||||||
city,
|
|
||||||
}, candidateId)
|
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createCandidate() {
|
||||||
|
// create candidate
|
||||||
|
const candidateId = await client.createDoc(recruit.class.Candidate, space, {
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
email: '',
|
||||||
|
phone: '',
|
||||||
|
city,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (resumeName !== undefined) {
|
||||||
// create attachment
|
// create attachment
|
||||||
client.createDoc(chunter.class.Attachment, space, {
|
client.createDoc(chunter.class.Attachment, space, {
|
||||||
attachmentTo: candidateId,
|
attachmentTo: candidateId,
|
||||||
collection: 'resume',
|
collection: 'resume',
|
||||||
name: file.name,
|
name: resumeName,
|
||||||
file: uuid
|
file: resumeUuid
|
||||||
})
|
}, resumeId)
|
||||||
} finally {
|
|
||||||
loading = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop(event: DragEvent) {
|
function drop(event: DragEvent) {
|
||||||
@ -104,11 +123,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="abs-lb-content">
|
<div class="abs-lb-content">
|
||||||
<Button label={'Upload resume'} {loading} icon={FileUpload} size={'small'} transparent primary on:click={() => { inputFile.click() }}/>
|
{#if resumeName}
|
||||||
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected}/>
|
<a href="#">{resumeName}</a>
|
||||||
|
{: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}/>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="abs-rb-content">
|
<div class="abs-rb-content">
|
||||||
<Button label={'Save'} size={'small'} transparent />
|
<Button label={'Save'} size={'small'} transparent on:click={createCandidate}/>
|
||||||
</div>
|
</div>
|
||||||
<div class="abs-rt-content">
|
<div class="abs-rt-content">
|
||||||
<Grid column={2} columnGap={.5}>
|
<Grid column={2} columnGap={.5}>
|
||||||
|
Loading…
Reference in New Issue
Block a user