From eb2fa1aad1fc78b65aacaff7aa2492c851efdc3b Mon Sep 17 00:00:00 2001 From: Andrey Platov Date: Thu, 9 Sep 2021 16:00:47 +0200 Subject: [PATCH] add resume to existing candidate Signed-off-by: Andrey Platov --- .../src/components/ChannelsPresenter.svelte | 4 ++-- .../src/components/DialogHeader.svelte | 6 +++++- .../src/components/EditCandidate.svelte | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/contact-resources/src/components/ChannelsPresenter.svelte b/plugins/contact-resources/src/components/ChannelsPresenter.svelte index 99e2506ff5..53bd7588f0 100644 --- a/plugins/contact-resources/src/components/ChannelsPresenter.svelte +++ b/plugins/contact-resources/src/components/ChannelsPresenter.svelte @@ -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[] = [] diff --git a/plugins/recruit-resources/src/components/DialogHeader.svelte b/plugins/recruit-resources/src/components/DialogHeader.svelte index 1ae3e80b19..093e0d8032 100644 --- a/plugins/recruit-resources/src/components/DialogHeader.svelte +++ b/plugins/recruit-resources/src/components/DialogHeader.svelte @@ -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() 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 { diff --git a/plugins/recruit-resources/src/components/EditCandidate.svelte b/plugins/recruit-resources/src/components/EditCandidate.svelte index 3e2dc6fcf2..15642a0309 100644 --- a/plugins/recruit-resources/src/components/EditCandidate.svelte +++ b/plugins/recruit-resources/src/components/EditCandidate.svelte @@ -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 = {} - 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')