add title and fix attachments

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-12 16:47:49 +02:00
parent f59ca31d5d
commit 369f73f2e4
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
7 changed files with 740 additions and 727 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,9 @@ export class TCandidates extends TSpace implements Candidates {}
export class TCandidate extends TPerson implements Candidate {
@Prop(TypeString(), 'Resume' as IntlString)
resume?: Ref<Attachment>
@Prop(TypeString(), 'Title' as IntlString)
title?: Ref<Attachment>
}
@Model(recruit.class.Applicant, core.class.Doc, DOMAIN_RECRUIT)

View File

@ -17,9 +17,12 @@
import { CircleButton, IconAdd } from '@anticrm/ui'
import type { Doc, Ref, Space } from '@anticrm/core'
import { createQuery } from '@anticrm/presentation'
import { generateId } from '@anticrm/core'
import { createQuery, getClient } from '@anticrm/presentation'
import type { Attachment } from '@anticrm/chunter'
import { uploadFile } from '../utils'
import chunter from '@anticrm/chunter'
export let object: Doc
@ -30,12 +33,43 @@
const query = createQuery()
$: query.query(chunter.class.Attachment, { attachmentTo: object._id }, result => { files = result})
let inputFile: HTMLInputElement
let loading = false
const client = getClient()
async function createAttachment(file: File) {
loading = true
try {
const id = generateId<Attachment>()
const uuid = await uploadFile(id, object.space, file)
console.log('uploaded file uuid', uuid)
client.createDoc(chunter.class.Attachment, object.space, {
attachmentTo: object._id,
collection: 'attachment',
name: file.name,
file: uuid,
type: file.type,
size: file.size,
})
} finally {
loading = false
}
}
function fileSelected() {
console.log(inputFile.files)
const file = inputFile.files?.[0]
if (file !== undefined) { createAttachment(file) }
}
</script>
<div class="attachments-container">
<div class="flex-row-center">
<span class="title">Attachments</span>
<CircleButton icon={IconAdd} size={'small'} />
<a href={'#'} on:click={ () => { inputFile.click() } }><CircleButton icon={IconAdd} size={'small'} /></a>
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected}/>
</div>
<table class="table-body">
<thead>

View File

@ -17,6 +17,7 @@
import { createEventDispatcher } from 'svelte'
import type { Ref, Space, Doc } from '@anticrm/core'
import { Tabs, EditBox, Link, showPopup, IconFile as FileIcon } from '@anticrm/ui'
import type { Attachment } from '@anticrm/chunter'
import FileUpload from './icons/FileUpload.svelte'
import PDFViewer from './PDFViewer.svelte'
import { getClient, Channels } from '@anticrm/presentation'
@ -32,87 +33,14 @@
import recruit from '../plugin'
export let object: Candidate
export let space: Ref<Space>
const newValue = Object.assign({}, object)
let resume = {} as {
id: Ref<Doc> | undefined
name: string
uuid: string
size: number
type: string
}
const dispatch = createEventDispatcher()
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 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')
}
const tabModel = [
// {
// label: 'General',
// component: 'recruit:component:CandidateGeneral',
// props: {
// object,
// newValue,
// }
// },
{
label: 'Activity',
component: 'chunter:component:Activity',
props: {
object,
space
}
},
{
label: 'Attachments',
component: 'recruit:component:Attachments',
props: {
object,
space
}
}
]
let inputFile: HTMLInputElement
const dispatch = createEventDispatcher()
</script>
<!-- <div class="container">
<DialogHeader {space} {object} {newValue} {resume} on:save={ save }/>
<div class="tabs-container">
<Tabs model={tabModel}/>
</div>
</div> -->
<Panel icon={Contact} label={object.firstName + ' ' + object.lastName} on:save={ save } on:close={() => { dispatch('close') }}>
<Panel icon={Contact} label={object.firstName + ' ' + object.lastName} on:close={() => { dispatch('close') }}>
<svelte:fragment slot="subtitle">
<div class="flex-row-reverse" style="width: 100%">
<Channels value={object.channels} reverse />
@ -127,15 +55,8 @@
<div class="flex-col">
<div class="name"><EditBox placeholder="Name" maxWidth="15rem" bind:value={object.firstName}/></div>
<div class="name"><EditBox placeholder="Surname" maxWidth="15rem" bind:value={object.lastName}/></div>
<div class="city"><EditBox placeholder="Title" maxWidth="15rem" bind:value={object.title}/></div>
<div class="city"><EditBox placeholder="Location" maxWidth="15rem" bind:value={object.city}/></div>
<div class="flex resume">
{#if resume.id}
<Link label={resume.name} href={'#'} icon={FileIcon} on:click={ () => { showPopup(PDFViewer, { file: resume.uuid }, 'right') } }/>
{:else}
<a href={'#'} on:click={ () => { inputFile.click() } }>Upload resume</a>
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" />
{/if}
</div>
</div>
</div>

View File

@ -34,6 +34,7 @@ export interface Candidates extends Space {}
*/
export interface Candidate extends Person {
resume?: Ref<Attachment>
title?: string
}
/**

File diff suppressed because it is too large Load Diff