mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
CreateCandidate
updates
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
669c73b590
commit
f7086d9bdd
@ -16,8 +16,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import type { Ref, Space, Doc } from '@anticrm/core'
|
import type { Ref, Space, Doc } from '@anticrm/core'
|
||||||
|
import { generateId } from '@anticrm/core'
|
||||||
|
|
||||||
import { getClient, Card, Channels } from '@anticrm/presentation'
|
import { getClient, Card, Channels } from '@anticrm/presentation'
|
||||||
|
import { uploadFile } from '../utils'
|
||||||
|
|
||||||
import recruit from '../plugin'
|
import recruit from '../plugin'
|
||||||
import chunter from '@anticrm/chunter'
|
import chunter from '@anticrm/chunter'
|
||||||
@ -38,12 +40,13 @@
|
|||||||
|
|
||||||
export let space: Ref<Space>
|
export let space: Ref<Space>
|
||||||
|
|
||||||
|
let _space = space
|
||||||
|
|
||||||
const object: Candidate = {
|
const object: Candidate = {
|
||||||
lastName: '',
|
lastName: '',
|
||||||
firstName: '',
|
firstName: '',
|
||||||
city: ''
|
city: ''
|
||||||
} as Candidate
|
} as Candidate
|
||||||
const newValue = Object.assign({}, object)
|
|
||||||
|
|
||||||
let resume = {} as {
|
let resume = {} as {
|
||||||
id: Ref<Attachment> | undefined
|
id: Ref<Attachment> | undefined
|
||||||
@ -57,21 +60,21 @@
|
|||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
async function createCandidate() {
|
async function createCandidate() {
|
||||||
console.log(newValue)
|
console.log(_space)
|
||||||
// create candidate
|
// create candidate
|
||||||
const candidateId = await client.createDoc(recruit.class.Candidate, space, {
|
const candidateId = await client.createDoc(recruit.class.Candidate, _space, {
|
||||||
firstName: newValue.firstName,
|
firstName: object.firstName,
|
||||||
lastName: newValue.lastName,
|
lastName: object.lastName,
|
||||||
city: newValue.city,
|
city: object.city,
|
||||||
channels: newValue.channels,
|
channels: object.channels,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('resume name', resume.name)
|
console.log('resume name', resume.name)
|
||||||
|
|
||||||
if (resume.id !== undefined) {
|
if (resume.id !== undefined) {
|
||||||
// create attachment
|
// create attachment
|
||||||
console.log('creaing attachment space', space)
|
console.log('creaing attachment space', _space)
|
||||||
client.createDoc(chunter.class.Attachment, space, {
|
client.createDoc(chunter.class.Attachment, _space, {
|
||||||
attachmentTo: candidateId,
|
attachmentTo: candidateId,
|
||||||
collection: 'resume',
|
collection: 'resume',
|
||||||
name: resume.name,
|
name: resume.name,
|
||||||
@ -80,7 +83,7 @@
|
|||||||
size: resume.size,
|
size: resume.size,
|
||||||
}, resume.id)
|
}, resume.id)
|
||||||
|
|
||||||
client.updateDoc(recruit.class.Candidate, space, candidateId, {
|
client.updateDoc(recruit.class.Candidate, _space, candidateId, {
|
||||||
resume: resume.id
|
resume: resume.id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -89,18 +92,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let inputFile: HTMLInputElement
|
let inputFile: HTMLInputElement
|
||||||
let kl: number = 0
|
let loading = false
|
||||||
let changed = false
|
|
||||||
|
|
||||||
function isChanged(): void {
|
async function createAttachment(file: File) {
|
||||||
for (const key in newValue) {
|
loading = true
|
||||||
if (!equals((newValue as any)[key], (object as any)[key])) {
|
try {
|
||||||
changed = true
|
const id = generateId<Attachment>()
|
||||||
return
|
resume.uuid = await uploadFile(id, space, file)
|
||||||
|
resume.id = id
|
||||||
|
resume.name = file.name
|
||||||
|
resume.size = file.size
|
||||||
|
resume.type = file.type
|
||||||
|
|
||||||
|
object.resume = id
|
||||||
|
|
||||||
|
console.log('uploaded file uuid', resume.uuid)
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changed = false
|
|
||||||
|
function fileSelected() {
|
||||||
|
console.log(inputFile.files)
|
||||||
|
const file = inputFile.files?.[0]
|
||||||
|
if (file !== undefined) { createAttachment(file) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let kl: number = 0
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- <DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/> -->
|
<!-- <DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/> -->
|
||||||
@ -108,7 +127,9 @@
|
|||||||
<Card label={'Create Candidate'}
|
<Card label={'Create Candidate'}
|
||||||
okLabel={'Save'}
|
okLabel={'Save'}
|
||||||
okAction={createCandidate}
|
okAction={createCandidate}
|
||||||
bind:space={space}
|
canSave={object.firstName.length > 0 && object.lastName.length > 0}
|
||||||
|
spaceClass={recruit.class.Candidates}
|
||||||
|
bind:space={_space}
|
||||||
on:close={() => { dispatch('close') }}>
|
on:close={() => { dispatch('close') }}>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
@ -126,22 +147,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
<div class="name"><EditBox placeholder="Name*" maxWidth="9.5rem"/></div>
|
<div class="name"><EditBox placeholder="John" maxWidth="9.5rem" bind:value={object.firstName}/></div>
|
||||||
<div class="name"><EditBox placeholder="Surname*" maxWidth="9.5rem" /></div>
|
<div class="name"><EditBox placeholder="Appleseed" maxWidth="9.5rem" bind:value={object.lastName}/></div>
|
||||||
<div class="city"><EditBox placeholder="Location" maxWidth="9.5rem" /></div>
|
<div class="city"><EditBox placeholder="Location" maxWidth="9.5rem" bind:value={object.city}/></div>
|
||||||
<div class="flex resume">
|
<div class="flex resume">
|
||||||
{#if kl === 0}
|
{#if resume.id}
|
||||||
<a href={'#'} on:click={ () => { showPopup(PDFViewer, { file: resume.uuid }, 'right') } }>Upload resume</a>
|
<Link label={resume.name} href={'#'} icon={FileIcon} on:click={ () => { showPopup(PDFViewer, { file: resume.uuid }, 'right') } }/>
|
||||||
{:else}
|
{:else}
|
||||||
<a href={'#'} on:click={ () => { inputFile.click() } }>Resume</a>
|
<a href={'#'} on:click={ () => { inputFile.click() } }>Upload resume</a>
|
||||||
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change/>
|
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected}/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<svelte:fragment slot="contacts">
|
<svelte:fragment slot="contacts">
|
||||||
<Channels value={newValue.channels} />
|
<Channels value={object.channels} />
|
||||||
<CircleButton icon={Edit} label={'Edit'} on:click={(ev) => showPopup(SocialEditor, { values: newValue.channels ?? [] }, ev.target, (result) => { newValue.channels = result; isChanged() })} />
|
<CircleButton icon={Edit} label={'Edit'} on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { object.channels = result })} />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user