2021-08-07 17:03:06 +00:00
|
|
|
<!--
|
|
|
|
// 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'
|
2021-08-30 10:17:15 +00:00
|
|
|
import type { Ref, Space, Doc } from '@anticrm/core'
|
2021-08-17 13:09:15 +00:00
|
|
|
import { TextArea, EditBox, Dialog, Tabs, Section, Grid } from '@anticrm/ui'
|
2021-08-07 17:03:06 +00:00
|
|
|
import File from './icons/File.svelte'
|
|
|
|
import Address from './icons/Address.svelte'
|
|
|
|
import Attachment from './icons/Attachment.svelte'
|
2021-08-17 13:09:15 +00:00
|
|
|
import DialogHeader from './DialogHeader.svelte'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
import { getClient } from '@anticrm/presentation'
|
|
|
|
|
|
|
|
import recruit from '../plugin'
|
2021-08-30 10:17:15 +00:00
|
|
|
import chunter from '@anticrm/chunter'
|
|
|
|
import { Candidate } from '@anticrm/recruit'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
export let space: Ref<Space>
|
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
const object: Candidate = {
|
|
|
|
lastName: '',
|
|
|
|
firstName: '',
|
|
|
|
city: ''
|
|
|
|
} as Candidate
|
|
|
|
const newValue = Object.assign({}, object)
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-08-30 17:50:33 +00:00
|
|
|
let resume = {} as {
|
|
|
|
id: Ref<Doc> | undefined
|
|
|
|
name: string
|
|
|
|
uuid: string
|
|
|
|
size: number
|
|
|
|
type: string
|
|
|
|
}
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
2021-08-07 17:03:06 +00:00
|
|
|
const client = getClient()
|
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
async function createCandidate() {
|
|
|
|
console.log(newValue)
|
|
|
|
// create candidate
|
|
|
|
const candidateId = await client.createDoc(recruit.class.Candidate, space, {
|
|
|
|
firstName: newValue.firstName,
|
|
|
|
lastName: newValue.lastName,
|
|
|
|
email: '',
|
|
|
|
phone: '',
|
|
|
|
city: newValue.city,
|
2021-08-07 17:03:06 +00:00
|
|
|
})
|
2021-08-30 10:17:15 +00:00
|
|
|
|
2021-08-30 17:50:33 +00:00
|
|
|
console.log('resume name', resume.name)
|
|
|
|
|
|
|
|
if (resume.id !== undefined) {
|
2021-08-30 10:17:15 +00:00
|
|
|
// create attachment
|
2021-08-30 17:50:33 +00:00
|
|
|
console.log('creaing attachment space', space)
|
2021-08-30 10:17:15 +00:00
|
|
|
client.createDoc(chunter.class.Attachment, space, {
|
|
|
|
attachmentTo: candidateId,
|
|
|
|
collection: 'resume',
|
2021-08-30 17:50:33 +00:00
|
|
|
name: resume.name,
|
|
|
|
file: resume.uuid,
|
|
|
|
type: resume.type,
|
|
|
|
size: resume.size,
|
|
|
|
}, resume.id)
|
2021-08-30 10:17:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dispatch('close')
|
2021-08-07 17:03:06 +00:00
|
|
|
}
|
2021-08-30 10:17:15 +00:00
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2021-08-30 17:50:33 +00:00
|
|
|
<DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/>
|