add resume to existing candidate

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-09 16:00:47 +02:00
parent 5455507e1f
commit eb2fa1aad1
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
3 changed files with 25 additions and 4 deletions

View File

@ -25,7 +25,7 @@ import IconCopy from './icons/Copy.svelte'
import contact from '@anticrm/contact'
export let value: Channel[] | undefined
export let value: Channel[] | null
interface Item {
label: IntlString,
@ -60,7 +60,7 @@ async function update(value: Channel[]) {
displayItems = result
}
$: if (value !== undefined) update(value)
$: if (value) update(value)
let displayItems: Item[] = []

View File

@ -22,6 +22,7 @@
import { EditBox, Button, CircleButton, Grid, Label, Link, showPopup, Component, IconFile as FileIcon } from '@anticrm/ui'
import type { AnyComponent } from '@anticrm/ui'
import { getClient } from '@anticrm/presentation'
import type { Attachment } from '@anticrm/chunter'
import AvatarEditor from './AvatarEditor.svelte'
import FileUpload from './icons/FileUpload.svelte'
@ -87,13 +88,16 @@
async function createAttachment(file: File) {
loading = true
try {
const id = generateId()
const id = generateId<Attachment>()
resume.uuid = await uploadFile(id, space, file)
resume.id = id
resume.name = file.name
resume.size = file.size
resume.type = file.type
newValue.resume = id
isChanged()
console.log('uploaded file uuid', resume.uuid)
} finally {

View File

@ -20,6 +20,8 @@
import { getClient } from '@anticrm/presentation'
import type { Candidate } from '@anticrm/recruit'
import DialogHeader from './DialogHeader.svelte'
import chunter from '@anticrm/chunter'
import recruit from '../plugin'
@ -40,12 +42,27 @@
const client = getClient()
async function save() {
if (resume.id !== undefined) {
// create attachment
console.log('creaing attachment space', space)
client.createDoc(chunter.class.Attachment, space, {
attachmentTo: object._id,
collection: 'resume',
name: resume.name,
file: resume.uuid,
type: resume.type,
size: resume.size,
}, resume.id)
}
const attributes: Record<string, any> = {}
for (const key in object) {
for (const key in newValue) {
if ((newValue as any)[key] !== (object as any)[key]) {
attributes[key] = (newValue as any)[key]
}
}
console.log('update attributes', attributes)
await client.updateDoc(recruit.class.Candidate, object.space, object._id, attributes)
dispatch('close')