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-09-15 17:03:34 +00:00
|
|
|
import type { Ref, Space, Data } from '@anticrm/core'
|
2021-09-10 16:59:11 +00:00
|
|
|
import { generateId } from '@anticrm/core'
|
2021-09-15 17:03:34 +00:00
|
|
|
import { setPlatformStatus, unknownError } from '@anticrm/platform'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-09-10 14:26:16 +00:00
|
|
|
import { getClient, Card, Channels } from '@anticrm/presentation'
|
2021-09-10 16:59:11 +00:00
|
|
|
import { uploadFile } from '../utils'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
import recruit from '../plugin'
|
2021-08-30 10:17:15 +00:00
|
|
|
import chunter from '@anticrm/chunter'
|
2021-08-31 14:54:47 +00:00
|
|
|
import type { Candidate } from '@anticrm/recruit'
|
|
|
|
import type { Attachment } from '@anticrm/chunter'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
import { EditBox, Link, showPopup, Component, CircleButton, IconFile as FileIcon, Spinner } from '@anticrm/ui'
|
2021-09-10 06:41:22 +00:00
|
|
|
import FileUpload from './icons/FileUpload.svelte'
|
|
|
|
import Avatar from './icons/Avatar.svelte'
|
2021-09-10 14:26:16 +00:00
|
|
|
import Edit from './icons/Edit.svelte'
|
|
|
|
import SocialEditor from './SocialEditor.svelte'
|
2021-09-10 06:41:22 +00:00
|
|
|
import PDFViewer from './PDFViewer.svelte'
|
|
|
|
import Girl from '../../img/girl.png'
|
|
|
|
import Elon from '../../img/elon.png'
|
|
|
|
import Bond from '../../img/bond.png'
|
|
|
|
|
2021-09-10 14:26:16 +00:00
|
|
|
import equals from 'deep-equal'
|
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
export let space: Ref<Space>
|
|
|
|
|
2021-09-10 16:59:11 +00:00
|
|
|
let _space = space
|
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
const object: Candidate = {
|
|
|
|
lastName: '',
|
|
|
|
firstName: '',
|
|
|
|
city: ''
|
|
|
|
} as Candidate
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-08-30 17:50:33 +00:00
|
|
|
let resume = {} as {
|
|
|
|
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-09-15 17:03:34 +00:00
|
|
|
const candidateId = generateId()
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
async function createCandidate() {
|
2021-09-15 17:03:34 +00:00
|
|
|
const candidate: Data<Candidate> = {
|
2021-09-10 16:59:11 +00:00
|
|
|
firstName: object.firstName,
|
|
|
|
lastName: object.lastName,
|
|
|
|
city: object.city,
|
|
|
|
channels: object.channels,
|
2021-09-15 17:03:34 +00:00
|
|
|
attachments: {}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 10:17:15 +00:00
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
await client.createDoc(recruit.class.Candidate, _space, candidate, candidateId)
|
2021-08-30 17:50:33 +00:00
|
|
|
console.log('resume name', resume.name)
|
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
// 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
|
|
|
|
// })
|
|
|
|
// }
|
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-09-10 06:41:22 +00:00
|
|
|
let inputFile: HTMLInputElement
|
2021-09-10 16:59:11 +00:00
|
|
|
let loading = false
|
|
|
|
|
|
|
|
async function createAttachment(file: File) {
|
|
|
|
loading = true
|
|
|
|
try {
|
2021-09-15 17:03:34 +00:00
|
|
|
resume.uuid = await uploadFile(space, file, candidateId)
|
2021-09-10 16:59:11 +00:00
|
|
|
resume.name = file.name
|
|
|
|
resume.size = file.size
|
|
|
|
resume.type = file.type
|
|
|
|
|
|
|
|
console.log('uploaded file uuid', resume.uuid)
|
2021-09-15 17:03:34 +00:00
|
|
|
} catch (err: any) {
|
|
|
|
setPlatformStatus(unknownError(err))
|
2021-09-10 16:59:11 +00:00
|
|
|
} finally {
|
|
|
|
loading = false
|
2021-09-10 14:26:16 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-10 16:59:11 +00:00
|
|
|
|
|
|
|
function fileSelected() {
|
|
|
|
console.log(inputFile.files)
|
|
|
|
const file = inputFile.files?.[0]
|
|
|
|
if (file !== undefined) { createAttachment(file) }
|
|
|
|
}
|
|
|
|
|
|
|
|
let kl: number = 0
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-10 06:41:22 +00:00
|
|
|
<!-- <DialogHeader {space} {object} {newValue} {resume} create={true} on:save={createCandidate}/> -->
|
|
|
|
|
|
|
|
<Card label={'Create Candidate'}
|
|
|
|
okLabel={'Save'}
|
|
|
|
okAction={createCandidate}
|
2021-09-10 16:59:11 +00:00
|
|
|
canSave={object.firstName.length > 0 && object.lastName.length > 0}
|
|
|
|
spaceClass={recruit.class.Candidates}
|
2021-09-11 06:38:54 +00:00
|
|
|
spaceLabel={'Talent Pool'}
|
|
|
|
spacePlaceholder={'Select pool'}
|
2021-09-10 16:59:11 +00:00
|
|
|
bind:space={_space}
|
2021-09-10 06:41:22 +00:00
|
|
|
on:close={() => { dispatch('close') }}>
|
|
|
|
|
|
|
|
<div class="flex">
|
|
|
|
<div class="avatar" on:click={() => { (kl < 3) ? kl++ : kl = 0 }}>
|
|
|
|
<div class="border"/>
|
|
|
|
{#if kl === 0}
|
|
|
|
<Avatar />
|
|
|
|
{:else if kl === 1}
|
|
|
|
<img src={Girl} alt="Avatar" />
|
|
|
|
{:else if kl === 2}
|
|
|
|
<img src={Elon} alt="Avatar" />
|
|
|
|
{:else}
|
|
|
|
<img src={Bond} alt="Avatar" />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex-col">
|
2021-09-10 16:59:11 +00:00
|
|
|
<div class="name"><EditBox placeholder="John" maxWidth="9.5rem" bind:value={object.firstName}/></div>
|
|
|
|
<div class="name"><EditBox placeholder="Appleseed" maxWidth="9.5rem" bind:value={object.lastName}/></div>
|
|
|
|
<div class="city"><EditBox placeholder="Location" maxWidth="9.5rem" bind:value={object.city}/></div>
|
2021-09-10 06:41:22 +00:00
|
|
|
<div class="flex resume">
|
2021-09-15 17:03:34 +00:00
|
|
|
{#if resume.uuid}
|
2021-09-10 16:59:11 +00:00
|
|
|
<Link label={resume.name} href={'#'} icon={FileIcon} on:click={ () => { showPopup(PDFViewer, { file: resume.uuid }, 'right') } }/>
|
2021-09-10 06:41:22 +00:00
|
|
|
{:else}
|
2021-09-15 17:03:34 +00:00
|
|
|
{#if loading}
|
|
|
|
<Spinner/> Uploading...
|
|
|
|
{:else}
|
|
|
|
<FileUpload size='small'/>
|
|
|
|
<a href={'#'} on:click={ () => { inputFile.click() } }>Upload resume</a>
|
|
|
|
{/if}
|
2021-09-10 16:59:11 +00:00
|
|
|
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected}/>
|
2021-09-10 06:41:22 +00:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-10 14:26:16 +00:00
|
|
|
<svelte:fragment slot="contacts">
|
2021-09-10 16:59:11 +00:00
|
|
|
<Channels value={object.channels} />
|
|
|
|
<CircleButton icon={Edit} label={'Edit'} on:click={(ev) => showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { object.channels = result })} />
|
2021-09-10 14:26:16 +00:00
|
|
|
</svelte:fragment>
|
2021-09-10 06:41:22 +00:00
|
|
|
</Card>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '../../../../packages/theme/styles/mixins.scss';
|
|
|
|
|
|
|
|
.avatar {
|
2021-09-10 14:26:16 +00:00
|
|
|
flex-shrink: 0;
|
2021-09-10 06:41:22 +00:00
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
margin-right: 1rem;
|
|
|
|
width: 6rem;
|
|
|
|
height: 6rem;
|
|
|
|
border-radius: 50%;
|
|
|
|
filter: var(--theme-avatar-shadow);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
content: '';
|
|
|
|
@include bg-layer(var(--theme-avatar-hover), .5);
|
|
|
|
z-index: -1;
|
|
|
|
}
|
|
|
|
&::before {
|
|
|
|
content: '';
|
|
|
|
@include bg-layer(var(--theme-avatar-bg), .1);
|
|
|
|
backdrop-filter: blur(25px);
|
|
|
|
z-index: -2;
|
|
|
|
}
|
|
|
|
.border {
|
|
|
|
@include bg-fullsize;
|
|
|
|
border: 2px solid var(--theme-avatar-border);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 1.25rem;
|
|
|
|
color: var(--theme-caption-color);
|
|
|
|
}
|
|
|
|
.city {
|
|
|
|
margin: .75rem 0 .125rem;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: .75rem;
|
|
|
|
color: var(--theme-content-color);
|
|
|
|
}
|
|
|
|
.resume a {
|
|
|
|
font-size: .75rem;
|
|
|
|
color: var(--theme-content-dark-color);
|
|
|
|
&:hover { color: var(--theme-content-color); }
|
|
|
|
}
|
|
|
|
</style>
|