mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-18 06:13:52 +00:00
fix CreateCandidate
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
a9f2e54e42
commit
bcc2e09d40
plugins/recruit-resources/src/components
@ -1,82 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import type { Ref, Space, Doc } from '@anticrm/core'
|
||||
import DialogHeader from './DialogHeader.svelte.txt'
|
||||
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
|
||||
import recruit from '../plugin'
|
||||
import chunter from '@anticrm/chunter'
|
||||
import type { Candidate } from '@anticrm/recruit'
|
||||
import type { Attachment } from '@anticrm/chunter'
|
||||
|
||||
export let space: Ref<Space>
|
||||
|
||||
const object: Candidate = {
|
||||
lastName: '',
|
||||
firstName: '',
|
||||
city: ''
|
||||
} as Candidate
|
||||
const newValue = Object.assign({}, object)
|
||||
|
||||
let resume = {} as {
|
||||
id: Ref<Attachment> | undefined
|
||||
name: string
|
||||
uuid: string
|
||||
size: number
|
||||
type: string
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
|
||||
async function createCandidate() {
|
||||
console.log(newValue)
|
||||
// create candidate
|
||||
const candidateId = await client.createDoc(recruit.class.Candidate, space, {
|
||||
firstName: newValue.firstName,
|
||||
lastName: newValue.lastName,
|
||||
city: newValue.city,
|
||||
channels: newValue.channels,
|
||||
})
|
||||
|
||||
console.log('resume name', resume.name)
|
||||
|
||||
if (resume.id !== undefined) {
|
||||
// create attachment
|
||||
console.log('creaing attachment space', space)
|
||||
client.createDoc(chunter.class.Attachment, space, {
|
||||
attachedTo: candidateId,
|
||||
collection: 'resume',
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
type: resume.type,
|
||||
size: resume.size,
|
||||
}, resume.id)
|
||||
|
||||
client.updateDoc(recruit.class.Candidate, space, candidateId, {
|
||||
resume: resume.id
|
||||
})
|
||||
}
|
||||
|
||||
dispatch('close')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/>
|
@ -1,72 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import type { Ref, Space } from '@anticrm/core'
|
||||
import { TextArea, EditBox, Dialog, Tabs, Section, Grid, IconFile } from '@anticrm/ui'
|
||||
import Address from './icons/Address.svelte'
|
||||
import Attachment from './icons/Attachment.svelte'
|
||||
import DialogHeader from './DialogHeader.svelte.txt'
|
||||
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
|
||||
import recruit from '../plugin'
|
||||
|
||||
export let space: Ref<Space>
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let firstName: string = ''
|
||||
let lastName: string = ''
|
||||
let email: string = ''
|
||||
let phone: string = ''
|
||||
let city: string = ''
|
||||
|
||||
const client = getClient()
|
||||
|
||||
function createCandidate() {
|
||||
client.createDoc(recruit.class.Candidate, space, {
|
||||
firstName,
|
||||
lastName,
|
||||
email,
|
||||
phone,
|
||||
city,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Dialog label={recruit.string.CreateCandidate}
|
||||
okLabel={recruit.string.CreateCandidate}
|
||||
okAction={createCandidate}
|
||||
on:close={() => { dispatch('close') }}>
|
||||
<DialogHeader />
|
||||
<Section icon={IconFile} label={'Personal Information'}>
|
||||
<Grid>
|
||||
<EditBox label={'First name *'} placeholder={'John'} bind:value={firstName} focus/>
|
||||
<EditBox label={'Last name *'} placeholder={'Smith'} bind:value={lastName}/>
|
||||
<EditBox label={'Email *'} placeholder={'john.smith@gmail.com'} bind:value={email}/>
|
||||
<EditBox label={'Phone *'} placeholder={'+00 (000) 000 00'} bind:value={phone}/>
|
||||
</Grid>
|
||||
</Section>
|
||||
<Section icon={Address} label={'Address'}>
|
||||
<Grid>
|
||||
<EditBox label={'Street'} placeholder={'Broderick st'} />
|
||||
<EditBox label={'City *'} placeholder={'Los Angeles'} bind:value={city}/>
|
||||
<EditBox label={'ZIP / Postal code'} placeholder={'26892'} />
|
||||
<EditBox label={'Country'} placeholder={'United States'} />
|
||||
</Grid>
|
||||
</Section>
|
||||
</Dialog>
|
@ -59,6 +59,7 @@
|
||||
uuid: string
|
||||
size: number
|
||||
type: string
|
||||
lastModified: number
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
@ -75,41 +76,27 @@
|
||||
remote: object.remote
|
||||
}
|
||||
|
||||
if (resume.uuid !== undefined) {
|
||||
candidate.attachments[encodeURIComponent(resume.uuid)] = {
|
||||
_class: chunter.class.Attachment,
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
size: resume.size,
|
||||
type: resume.type
|
||||
}
|
||||
}
|
||||
|
||||
await client.createDoc(recruit.class.Candidate, _space, candidate, candidateId)
|
||||
const id = await client.createDoc(recruit.class.Candidate, _space, candidate, candidateId)
|
||||
console.log('resume name', resume.name)
|
||||
|
||||
// if (resume.id !== undefined) {
|
||||
// // create attachment
|
||||
// console.log('creaing attachment space', _space)
|
||||
// client.createDoc(chunter.class.Attachment, _space, {
|
||||
// attachedTo: candidateId,
|
||||
// collection: 'resume',
|
||||
// name: resume.name,
|
||||
// file: resume.uuid,
|
||||
// type: resume.type,
|
||||
// size: resume.size,
|
||||
// }, resume.id)
|
||||
|
||||
// client.updateDoc(recruit.class.Candidate, _space, candidateId, {
|
||||
// resume: resume.id
|
||||
// })
|
||||
// }
|
||||
if (resume.uuid !== undefined) {
|
||||
client.createDoc(chunter.class.Attachment, space, {
|
||||
attachedTo: id,
|
||||
attachedToClass: recruit.class.Candidate,
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
size: resume.size,
|
||||
type: resume.type,
|
||||
lastModified: resume.lastModified
|
||||
})
|
||||
}
|
||||
|
||||
dispatch('close')
|
||||
}
|
||||
|
||||
let inputFile: HTMLInputElement
|
||||
let loading = false
|
||||
let dragover = false
|
||||
|
||||
async function createAttachment(file: File) {
|
||||
loading = true
|
||||
@ -118,6 +105,7 @@
|
||||
resume.name = file.name
|
||||
resume.size = file.size
|
||||
resume.type = file.type
|
||||
resume.lastModified = file.lastModified
|
||||
|
||||
console.log('uploaded file uuid', resume.uuid)
|
||||
} catch (err: any) {
|
||||
@ -127,17 +115,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
function drop(event: DragEvent) {
|
||||
dragover = false
|
||||
const droppedFile = event.dataTransfer?.files[0]
|
||||
if (droppedFile !== undefined) { createAttachment(droppedFile) }
|
||||
}
|
||||
|
||||
function fileSelected() {
|
||||
console.log(inputFile.files)
|
||||
const file = inputFile.files?.[0]
|
||||
if (file !== undefined) { createAttachment(file) }
|
||||
}
|
||||
|
||||
function saveChannels(result: any) {
|
||||
object.channels = result
|
||||
client.updateDoc(recruit.class.Candidate, object.space, object._id, { channels: result })
|
||||
}
|
||||
|
||||
let kl: number = 0
|
||||
</script>
|
||||
|
||||
@ -190,15 +179,18 @@
|
||||
|
||||
<div class="flex-row-center channels">
|
||||
{#if !object.channels || object.channels.length === 0}
|
||||
<CircleButton icon={IconAdd} size={'small'} selected on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { saveChannels(result) })} />
|
||||
<CircleButton icon={IconAdd} size={'small'} selected on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { object.channels = result })} />
|
||||
<span><Label label={'Add social links'} /></span>
|
||||
{:else}
|
||||
<Channels value={object.channels} size={'small'} />
|
||||
<CircleButton icon={Edit} size={'small'} selected on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { saveChannels(result) })} />
|
||||
<CircleButton icon={Edit} size={'small'} selected on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { object.channels = result })} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex-center resume" class:solid={resume.uuid}>
|
||||
<div class="flex-center resume" class:solid={dragover}
|
||||
on:dragover|preventDefault={ () => { dragover = true } }
|
||||
on:dragleave={ () => { dragover = false } }
|
||||
on:drop|preventDefault|stopPropagation={drop}>
|
||||
{#if resume.uuid}
|
||||
<Link label={resume.name} href={'#'} icon={FileIcon} maxLenght={16} on:click={ () => { showPopup(PDFViewer, { file: resume.uuid }, 'right') } }/>
|
||||
{:else}
|
||||
|
Loading…
Reference in New Issue
Block a user