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">
|
2022-09-21 08:08:25 +00:00
|
|
|
import attachment from '@hcengineering/attachment'
|
2022-12-14 04:52:41 +00:00
|
|
|
import { deleteFile } from '@hcengineering/attachment-resources/src/utils'
|
2022-09-21 08:08:25 +00:00
|
|
|
import contact, { Channel, ChannelProvider, combineName, findContacts, Person } from '@hcengineering/contact'
|
2023-03-22 02:48:57 +00:00
|
|
|
import { ChannelsDropdown, EditableAvatar, PersonPresenter } from '@hcengineering/contact-resources'
|
2022-09-21 08:08:25 +00:00
|
|
|
import {
|
|
|
|
Account,
|
|
|
|
AttachedData,
|
|
|
|
Data,
|
|
|
|
Doc,
|
2023-03-21 16:08:45 +00:00
|
|
|
fillDefaults,
|
2022-09-21 08:08:25 +00:00
|
|
|
generateId,
|
|
|
|
MixinData,
|
|
|
|
Ref,
|
2023-01-18 09:57:13 +00:00
|
|
|
toIdMap,
|
2022-09-21 08:08:25 +00:00
|
|
|
TxProcessor,
|
|
|
|
WithLookup
|
|
|
|
} from '@hcengineering/core'
|
|
|
|
import { getMetadata, getResource, setPlatformStatus, unknownError } from '@hcengineering/platform'
|
2023-03-22 02:48:57 +00:00
|
|
|
import presentation, {
|
2022-02-16 09:02:31 +00:00
|
|
|
Card,
|
|
|
|
createQuery,
|
2023-03-24 10:23:44 +00:00
|
|
|
DraftController,
|
|
|
|
draftsStore,
|
2022-02-16 09:02:31 +00:00
|
|
|
getClient,
|
2023-03-17 15:57:36 +00:00
|
|
|
InlineAttributeBar,
|
2022-02-16 09:02:31 +00:00
|
|
|
KeyedAttribute,
|
2022-12-14 04:52:41 +00:00
|
|
|
MessageBox,
|
2023-03-24 10:23:44 +00:00
|
|
|
PDFViewer
|
2022-09-21 08:08:25 +00:00
|
|
|
} from '@hcengineering/presentation'
|
2022-12-14 04:52:41 +00:00
|
|
|
import type { Candidate, CandidateDraft } from '@hcengineering/recruit'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { recognizeDocument } from '@hcengineering/rekoni'
|
|
|
|
import tags, { findTagCategory, TagElement, TagReference } from '@hcengineering/tags'
|
2022-02-16 09:02:31 +00:00
|
|
|
import {
|
2022-05-11 05:36:35 +00:00
|
|
|
Button,
|
2022-04-21 09:38:09 +00:00
|
|
|
Component,
|
2022-05-12 04:10:52 +00:00
|
|
|
createFocusManager,
|
2022-02-16 09:02:31 +00:00
|
|
|
EditBox,
|
2022-05-12 04:10:52 +00:00
|
|
|
FocusHandler,
|
2022-02-25 13:23:50 +00:00
|
|
|
getColorNumberByText,
|
|
|
|
IconFile as FileIcon,
|
|
|
|
IconInfo,
|
2022-02-16 09:02:31 +00:00
|
|
|
Label,
|
2022-02-25 13:23:50 +00:00
|
|
|
showPopup,
|
2022-04-19 09:38:31 +00:00
|
|
|
Spinner
|
2022-09-21 08:08:25 +00:00
|
|
|
} from '@hcengineering/ui'
|
2023-03-24 10:23:44 +00:00
|
|
|
import { createEventDispatcher, onDestroy } from 'svelte'
|
2022-01-06 11:38:40 +00:00
|
|
|
import recruit from '../plugin'
|
|
|
|
import FileUpload from './icons/FileUpload.svelte'
|
2021-09-22 14:06:21 +00:00
|
|
|
import YesNo from './YesNo.svelte'
|
|
|
|
|
2022-12-14 04:52:41 +00:00
|
|
|
export let shouldSaveDraft: boolean = false
|
2023-03-24 10:23:44 +00:00
|
|
|
|
|
|
|
const draftController = new DraftController<CandidateDraft>(recruit.mixin.Candidate)
|
|
|
|
|
|
|
|
function getEmptyCandidate (): CandidateDraft {
|
|
|
|
return {
|
|
|
|
_id: generateId(),
|
|
|
|
firstName: '',
|
|
|
|
lastName: '',
|
|
|
|
title: '',
|
|
|
|
channels: [],
|
|
|
|
skills: [],
|
|
|
|
city: ''
|
|
|
|
}
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
2023-03-24 10:23:44 +00:00
|
|
|
const empty = {}
|
|
|
|
const client = getClient()
|
|
|
|
const hierarchy = client.getHierarchy()
|
|
|
|
const ignoreKeys = ['onsite', 'remote']
|
|
|
|
|
|
|
|
const draft = shouldSaveDraft ? draftController.get() : undefined
|
|
|
|
let object = draft ?? getEmptyCandidate()
|
2022-12-14 04:52:41 +00:00
|
|
|
type resumeFile = {
|
|
|
|
name: string
|
|
|
|
uuid: string
|
|
|
|
size: number
|
|
|
|
type: string
|
|
|
|
lastModified: number
|
|
|
|
}
|
2022-05-11 05:36:35 +00:00
|
|
|
let createMore: boolean = false
|
2021-10-01 12:28:52 +00:00
|
|
|
|
2022-01-06 11:38:40 +00:00
|
|
|
export function canClose (): boolean {
|
2022-12-14 04:52:41 +00:00
|
|
|
return true
|
2021-10-12 10:11:45 +00:00
|
|
|
}
|
|
|
|
|
2022-10-31 05:34:42 +00:00
|
|
|
let avatarEditor: EditableAvatar
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
fillDefaults(hierarchy, empty, recruit.mixin.Candidate)
|
2023-03-21 16:08:45 +00:00
|
|
|
fillDefaults(hierarchy, object, recruit.mixin.Candidate)
|
2022-12-14 04:52:41 +00:00
|
|
|
|
|
|
|
function resumeDraft () {
|
|
|
|
return {
|
2023-03-24 10:23:44 +00:00
|
|
|
uuid: object?.resumeUuid,
|
|
|
|
name: object?.resumeName,
|
|
|
|
size: object?.resumeSize,
|
|
|
|
type: object?.resumeType,
|
|
|
|
lastModified: object?.resumeLastModified
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
2021-08-30 17:50:33 +00:00
|
|
|
}
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
if (shouldSaveDraft) {
|
|
|
|
draftController.watch(object, empty)
|
|
|
|
}
|
|
|
|
|
|
|
|
onDestroy(() => draftController.unsubscribe())
|
2022-12-14 04:52:41 +00:00
|
|
|
|
2021-08-30 10:17:15 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2022-02-16 09:02:31 +00:00
|
|
|
let inputFile: HTMLInputElement
|
|
|
|
let loading = false
|
|
|
|
let dragover = false
|
|
|
|
|
2022-12-14 04:52:41 +00:00
|
|
|
let avatar: File | undefined = draft?.avatar
|
2022-06-20 07:57:45 +00:00
|
|
|
|
|
|
|
let matches: WithLookup<Person>[] = []
|
|
|
|
let matchedChannels: AttachedData<Channel>[] = []
|
2022-02-16 09:02:31 +00:00
|
|
|
|
|
|
|
const key: KeyedAttribute = {
|
|
|
|
key: 'skills',
|
|
|
|
attr: client.getHierarchy().getAttribute(recruit.mixin.Candidate, 'skills')
|
|
|
|
}
|
|
|
|
|
|
|
|
let elements = new Map<Ref<TagElement>, TagElement>()
|
|
|
|
let namedElements = new Map<string, TagElement>()
|
|
|
|
|
|
|
|
const newElements: TagElement[] = []
|
|
|
|
|
|
|
|
const elementQuery = createQuery()
|
|
|
|
let elementsPromise: Promise<void>
|
|
|
|
$: elementsPromise = new Promise((resolve) => {
|
|
|
|
elementQuery.query(tags.class.TagElement, {}, (result) => {
|
|
|
|
const ne = new Map<Ref<TagElement>, TagElement>()
|
|
|
|
const nne = new Map<string, TagElement>()
|
|
|
|
for (const t of newElements.concat(result)) {
|
|
|
|
ne.set(t._id, t)
|
|
|
|
nne.set(t.title.trim().toLowerCase(), t)
|
|
|
|
}
|
|
|
|
elements = ne
|
|
|
|
namedElements = nne
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-01-06 11:38:40 +00:00
|
|
|
async function createCandidate () {
|
|
|
|
const candidate: Data<Person> = {
|
2023-03-24 10:23:44 +00:00
|
|
|
name: combineName(object.firstName ?? '', object.lastName ?? ''),
|
2023-02-09 16:50:30 +00:00
|
|
|
city: object.city,
|
2023-03-24 10:23:44 +00:00
|
|
|
channels: 0,
|
2023-02-09 16:50:30 +00:00
|
|
|
createOn: Date.now()
|
2022-03-28 15:25:39 +00:00
|
|
|
}
|
|
|
|
if (avatar !== undefined) {
|
2022-10-31 05:34:42 +00:00
|
|
|
candidate.avatar = await avatarEditor.createAvatar()
|
2022-01-06 11:38:40 +00:00
|
|
|
}
|
|
|
|
const candidateData: MixinData<Person, Candidate> = {
|
|
|
|
title: object.title,
|
2021-10-04 15:46:06 +00:00
|
|
|
onsite: object.onsite,
|
2023-03-24 10:23:44 +00:00
|
|
|
remote: object.remote,
|
|
|
|
skills: 0
|
2021-09-15 17:03:34 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 15:57:36 +00:00
|
|
|
// Store all extra values.
|
|
|
|
for (const [k, v] of Object.entries(object)) {
|
|
|
|
if (v != null && k !== 'createOn' && k !== 'avatar') {
|
2023-03-24 10:23:44 +00:00
|
|
|
const attr = hierarchy.findAttribute(recruit.mixin.Candidate, k)
|
|
|
|
if (attr === undefined) continue
|
|
|
|
if (attr.attributeOf === recruit.mixin.Candidate) {
|
|
|
|
if ((candidateData as any)[k] === undefined) {
|
|
|
|
;(candidateData as any)[k] = v
|
|
|
|
}
|
2023-03-17 15:57:36 +00:00
|
|
|
} else {
|
2023-03-24 10:23:44 +00:00
|
|
|
if ((candidate as any)[k] === undefined) {
|
|
|
|
;(candidate as any)[k] = v
|
|
|
|
}
|
2023-03-17 15:57:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
const applyOps = client.apply(object._id)
|
2023-03-17 15:57:36 +00:00
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
await applyOps.createDoc(contact.class.Person, contact.space.Contacts, candidate, object._id)
|
2023-03-17 15:57:36 +00:00
|
|
|
await applyOps.createMixin(
|
2023-03-24 10:23:44 +00:00
|
|
|
object._id,
|
2022-02-02 09:03:29 +00:00
|
|
|
contact.class.Person,
|
|
|
|
contact.space.Contacts,
|
|
|
|
recruit.mixin.Candidate,
|
|
|
|
candidateData
|
|
|
|
)
|
2022-01-06 11:38:40 +00:00
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
if (object.resumeUuid !== undefined) {
|
|
|
|
const resume = resumeDraft() as resumeFile
|
2023-03-17 15:57:36 +00:00
|
|
|
applyOps.addCollection(
|
2022-02-02 09:03:29 +00:00
|
|
|
attachment.class.Attachment,
|
|
|
|
contact.space.Contacts,
|
2023-03-24 10:23:44 +00:00
|
|
|
object._id,
|
2022-02-02 09:03:29 +00:00
|
|
|
contact.class.Person,
|
|
|
|
'attachments',
|
|
|
|
{
|
|
|
|
name: resume.name,
|
|
|
|
file: resume.uuid,
|
|
|
|
size: resume.size,
|
|
|
|
type: resume.type,
|
|
|
|
lastModified: resume.lastModified
|
|
|
|
}
|
|
|
|
)
|
2021-10-27 14:41:54 +00:00
|
|
|
}
|
2023-03-24 10:23:44 +00:00
|
|
|
for (const channel of object.channels) {
|
2023-03-17 15:57:36 +00:00
|
|
|
await applyOps.addCollection(
|
2022-02-02 09:03:29 +00:00
|
|
|
contact.class.Channel,
|
|
|
|
contact.space.Contacts,
|
2023-03-24 10:23:44 +00:00
|
|
|
object._id,
|
2022-02-02 09:03:29 +00:00
|
|
|
contact.class.Person,
|
|
|
|
'channels',
|
|
|
|
{
|
|
|
|
value: channel.value,
|
|
|
|
provider: channel.provider
|
|
|
|
}
|
|
|
|
)
|
2022-01-31 09:06:30 +00:00
|
|
|
}
|
2022-02-21 09:11:31 +00:00
|
|
|
|
2022-02-25 09:02:38 +00:00
|
|
|
const categories = await client.findAll(tags.class.TagCategory, { targetClass: recruit.mixin.Candidate })
|
2022-02-16 09:02:31 +00:00
|
|
|
// Tag elements
|
2023-01-18 09:57:13 +00:00
|
|
|
const skillTagElements = toIdMap(
|
2023-03-24 10:23:44 +00:00
|
|
|
await client.findAll(tags.class.TagElement, { _id: { $in: object.skills.map((it) => it.tag) } })
|
2022-02-25 13:23:50 +00:00
|
|
|
)
|
2023-03-24 10:23:44 +00:00
|
|
|
for (const skill of object.skills) {
|
2022-02-16 09:02:31 +00:00
|
|
|
// Create update tag if missing
|
|
|
|
if (!skillTagElements.has(skill.tag)) {
|
|
|
|
skill.tag = await client.createDoc(tags.class.TagElement, skill.space, {
|
|
|
|
title: skill.title,
|
|
|
|
color: skill.color,
|
|
|
|
targetClass: recruit.mixin.Candidate,
|
2022-02-21 09:11:31 +00:00
|
|
|
description: '',
|
|
|
|
category: findTagCategory(skill.title, categories)
|
2022-02-16 09:02:31 +00:00
|
|
|
})
|
|
|
|
}
|
2023-03-24 10:23:44 +00:00
|
|
|
await applyOps.addCollection(skill._class, skill.space, object._id, recruit.mixin.Candidate, 'skills', {
|
2022-02-16 09:02:31 +00:00
|
|
|
title: skill.title,
|
|
|
|
color: skill.color,
|
2022-11-29 15:22:33 +00:00
|
|
|
tag: skill.tag,
|
|
|
|
weight: skill.weight
|
2022-02-16 09:02:31 +00:00
|
|
|
})
|
|
|
|
}
|
2021-08-30 10:17:15 +00:00
|
|
|
|
2023-03-17 15:57:36 +00:00
|
|
|
await applyOps.commit()
|
2023-03-24 10:23:44 +00:00
|
|
|
draftController.remove()
|
2022-12-14 04:52:41 +00:00
|
|
|
if (!createMore) {
|
2023-03-24 10:23:44 +00:00
|
|
|
dispatch('close', object._id)
|
2022-05-11 05:36:35 +00:00
|
|
|
}
|
2022-12-14 04:52:41 +00:00
|
|
|
resetObject()
|
2021-08-07 17:03:06 +00:00
|
|
|
}
|
2021-08-30 10:17:15 +00:00
|
|
|
|
2022-02-02 09:03:29 +00:00
|
|
|
function isUndef (value?: string): boolean {
|
|
|
|
return value === undefined || value === ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function addChannel (channels: AttachedData<Channel>[], type: Ref<ChannelProvider>, value?: string): void {
|
|
|
|
if (value !== undefined) {
|
|
|
|
const provider = channels.find((e) => e.provider === type)
|
|
|
|
if (provider === undefined) {
|
|
|
|
channels.push({
|
|
|
|
provider: type,
|
|
|
|
value
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
if (isUndef(provider.value)) {
|
|
|
|
provider.value = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-15 16:36:50 +00:00
|
|
|
async function recognize (file: File): Promise<void> {
|
2023-03-22 02:48:57 +00:00
|
|
|
const token = getMetadata(presentation.metadata.Token) ?? ''
|
2022-02-02 09:03:29 +00:00
|
|
|
|
|
|
|
try {
|
2023-03-15 16:36:50 +00:00
|
|
|
const doc = await recognizeDocument(token, file)
|
2022-02-02 09:03:29 +00:00
|
|
|
|
2022-02-02 13:25:16 +00:00
|
|
|
if (isUndef(object.title) && doc.title !== undefined) {
|
|
|
|
object.title = doc.title
|
|
|
|
}
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
if (isUndef(object.firstName) && doc.firstName !== undefined) {
|
|
|
|
object.firstName = doc.firstName
|
2022-02-02 09:03:29 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
if (isUndef(object.lastName) && doc.lastName !== undefined) {
|
|
|
|
object.lastName = doc.lastName
|
2022-02-02 09:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isUndef(object.city) && doc.city !== undefined) {
|
|
|
|
object.city = doc.city
|
|
|
|
}
|
|
|
|
|
2022-10-31 05:34:42 +00:00
|
|
|
if (!object.avatar && doc.avatar !== undefined) {
|
2022-02-02 09:03:29 +00:00
|
|
|
// We had avatar, let's try to upload it.
|
|
|
|
const data = atob(doc.avatar)
|
|
|
|
let n = data.length
|
|
|
|
const u8arr = new Uint8Array(n)
|
|
|
|
while (n--) {
|
|
|
|
u8arr[n] = data.charCodeAt(n)
|
|
|
|
}
|
2022-02-02 16:46:37 +00:00
|
|
|
avatar = new File([u8arr], doc.avatarName ?? 'avatar.png', { type: doc.avatarFormat ?? 'image/png' })
|
2022-02-02 09:03:29 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
const newChannels = [...object.channels]
|
2022-02-02 09:03:29 +00:00
|
|
|
addChannel(newChannels, contact.channelProvider.Email, doc.email)
|
|
|
|
addChannel(newChannels, contact.channelProvider.GitHub, doc.github)
|
|
|
|
addChannel(newChannels, contact.channelProvider.LinkedIn, doc.linkedin)
|
|
|
|
addChannel(newChannels, contact.channelProvider.Phone, doc.phone)
|
|
|
|
addChannel(newChannels, contact.channelProvider.Telegram, doc.telegram)
|
|
|
|
addChannel(newChannels, contact.channelProvider.Twitter, doc.twitter)
|
2022-02-02 13:25:16 +00:00
|
|
|
addChannel(newChannels, contact.channelProvider.Facebook, doc.facebook)
|
2023-03-24 10:23:44 +00:00
|
|
|
object.channels = newChannels
|
2022-02-02 09:03:29 +00:00
|
|
|
|
2022-02-16 09:02:31 +00:00
|
|
|
// Create skills
|
|
|
|
await elementsPromise
|
|
|
|
|
2022-02-25 09:02:38 +00:00
|
|
|
const categories = await client.findAll(tags.class.TagCategory, { targetClass: recruit.mixin.Candidate })
|
2023-01-18 09:57:13 +00:00
|
|
|
const categoriesMap = toIdMap(categories)
|
2022-02-25 13:23:50 +00:00
|
|
|
|
|
|
|
const newSkills: TagReference[] = []
|
2022-04-29 05:27:17 +00:00
|
|
|
|
2022-02-16 09:02:31 +00:00
|
|
|
// Create missing tag elemnts
|
|
|
|
for (const s of doc.skills ?? []) {
|
|
|
|
const title = s.trim().toLowerCase()
|
|
|
|
let e = namedElements.get(title)
|
|
|
|
if (e === undefined) {
|
|
|
|
// No yet tag with title
|
2022-02-21 09:11:31 +00:00
|
|
|
const category = findTagCategory(s, categories)
|
|
|
|
const cinstance = categoriesMap.get(category)
|
2022-02-16 09:02:31 +00:00
|
|
|
e = TxProcessor.createDoc2Doc(
|
|
|
|
client.txFactory.createTxCreateDoc(tags.class.TagElement, tags.space.Tags, {
|
|
|
|
title,
|
2022-02-21 09:11:31 +00:00
|
|
|
description: `Imported skill ${s} of ${cinstance?.label ?? ''}`,
|
2022-02-16 09:02:31 +00:00
|
|
|
color: getColorNumberByText(s),
|
2022-02-21 09:11:31 +00:00
|
|
|
targetClass: recruit.mixin.Candidate,
|
|
|
|
category
|
2022-02-16 09:02:31 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
namedElements.set(title, e)
|
|
|
|
elements.set(e._id, e)
|
|
|
|
newElements.push(e)
|
|
|
|
}
|
|
|
|
newSkills.push(
|
|
|
|
TxProcessor.createDoc2Doc(
|
|
|
|
client.txFactory.createTxCreateDoc(tags.class.TagReference, tags.space.Tags, {
|
|
|
|
title: e.title,
|
|
|
|
color: e.color,
|
|
|
|
tag: e._id,
|
|
|
|
attachedTo: '' as Ref<Doc>,
|
|
|
|
attachedToClass: recruit.mixin.Candidate,
|
|
|
|
collection: 'skills'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2023-03-24 10:23:44 +00:00
|
|
|
object.skills = [...object.skills, ...newSkills]
|
2022-02-02 09:03:29 +00:00
|
|
|
} catch (err: any) {
|
|
|
|
console.error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 04:52:41 +00:00
|
|
|
async function deleteResume (): Promise<void> {
|
2023-03-24 10:23:44 +00:00
|
|
|
if (object.resumeUuid) {
|
2023-01-04 17:58:54 +00:00
|
|
|
try {
|
2023-03-24 10:23:44 +00:00
|
|
|
await deleteFile(object.resumeUuid)
|
2023-01-04 17:58:54 +00:00
|
|
|
} catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
}
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-06 11:38:40 +00:00
|
|
|
async function createAttachment (file: File) {
|
2021-09-10 16:59:11 +00:00
|
|
|
loading = true
|
|
|
|
try {
|
2022-01-12 09:52:22 +00:00
|
|
|
const uploadFile = await getResource(attachment.helper.UploadFile)
|
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
object.resumeUuid = await uploadFile(file)
|
|
|
|
object.resumeName = file.name
|
|
|
|
object.resumeSize = file.size
|
|
|
|
object.resumeType = file.type
|
|
|
|
object.resumeLastModified = file.lastModified
|
2021-09-10 16:59:11 +00:00
|
|
|
|
2023-03-15 16:36:50 +00:00
|
|
|
await recognize(file)
|
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
|
|
|
|
2022-01-06 11:38:40 +00:00
|
|
|
function drop (event: DragEvent) {
|
2021-10-27 14:41:54 +00:00
|
|
|
dragover = false
|
|
|
|
const droppedFile = event.dataTransfer?.files[0]
|
2022-02-02 09:03:29 +00:00
|
|
|
if (droppedFile !== undefined) {
|
|
|
|
createAttachment(droppedFile)
|
|
|
|
}
|
2022-01-06 11:38:40 +00:00
|
|
|
}
|
2021-10-27 14:41:54 +00:00
|
|
|
|
2022-01-06 11:38:40 +00:00
|
|
|
function fileSelected () {
|
2021-09-10 16:59:11 +00:00
|
|
|
console.log(inputFile.files)
|
|
|
|
const file = inputFile.files?.[0]
|
2022-02-02 09:03:29 +00:00
|
|
|
if (file !== undefined) {
|
|
|
|
createAttachment(file)
|
|
|
|
}
|
2022-05-12 04:10:52 +00:00
|
|
|
manager.setFocusPos(102)
|
2021-09-10 16:59:11 +00:00
|
|
|
}
|
2022-01-12 09:52:22 +00:00
|
|
|
|
2022-02-16 09:02:31 +00:00
|
|
|
function addTagRef (tag: TagElement): void {
|
2023-03-24 10:23:44 +00:00
|
|
|
object.skills = [
|
|
|
|
...object.skills,
|
2022-02-16 09:02:31 +00:00
|
|
|
{
|
|
|
|
_class: tags.class.TagReference,
|
|
|
|
_id: generateId() as Ref<TagReference>,
|
|
|
|
attachedTo: '' as Ref<Doc>,
|
|
|
|
attachedToClass: recruit.mixin.Candidate,
|
|
|
|
collection: 'skills',
|
|
|
|
space: tags.space.Tags,
|
|
|
|
modifiedOn: 0,
|
|
|
|
modifiedBy: '' as Ref<Account>,
|
|
|
|
title: tag.title,
|
|
|
|
tag: tag._id,
|
|
|
|
color: tag.color
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2023-03-24 10:23:44 +00:00
|
|
|
$: object.firstName &&
|
|
|
|
object.lastName &&
|
|
|
|
findContacts(
|
|
|
|
client,
|
|
|
|
contact.class.Person,
|
|
|
|
combineName(object.firstName.trim(), object.lastName.trim()),
|
|
|
|
object.channels
|
|
|
|
).then((p) => {
|
|
|
|
matches = p.contacts
|
|
|
|
matchedChannels = p.channels
|
|
|
|
})
|
2022-03-28 15:25:39 +00:00
|
|
|
|
2022-05-12 04:10:52 +00:00
|
|
|
const manager = createFocusManager()
|
2022-12-14 04:52:41 +00:00
|
|
|
|
|
|
|
function resetObject (): void {
|
2023-03-24 10:23:44 +00:00
|
|
|
object = getEmptyCandidate()
|
2023-03-21 16:08:45 +00:00
|
|
|
fillDefaults(hierarchy, object, recruit.mixin.Candidate)
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function onOutsideClick () {
|
2023-03-24 10:23:44 +00:00
|
|
|
if (shouldSaveDraft) {
|
|
|
|
draftController.save(object, empty)
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function showConfirmationDialog () {
|
2023-03-24 10:23:44 +00:00
|
|
|
draftController.save(object, empty)
|
|
|
|
const isFormEmpty = $draftsStore[recruit.mixin.Candidate] === undefined
|
2022-12-14 04:52:41 +00:00
|
|
|
|
|
|
|
if (isFormEmpty) {
|
|
|
|
dispatch('close')
|
|
|
|
} else {
|
|
|
|
showPopup(
|
|
|
|
MessageBox,
|
|
|
|
{
|
|
|
|
label: recruit.string.CreateTalentDialogClose,
|
|
|
|
message: recruit.string.CreateTalentDialogCloseNote
|
|
|
|
},
|
|
|
|
'top',
|
|
|
|
(result?: boolean) => {
|
|
|
|
if (result === true) {
|
|
|
|
dispatch('close')
|
|
|
|
deleteResume()
|
|
|
|
resetObject()
|
2023-03-24 10:23:44 +00:00
|
|
|
draftController.remove()
|
2022-12-14 04:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2022-02-25 13:23:50 +00:00
|
|
|
</script>
|
2021-09-10 06:41:22 +00:00
|
|
|
|
2022-05-12 04:10:52 +00:00
|
|
|
<FocusHandler {manager} />
|
|
|
|
|
2022-02-02 09:03:29 +00:00
|
|
|
<Card
|
2022-06-07 13:49:13 +00:00
|
|
|
label={recruit.string.CreateTalent}
|
2022-02-02 09:03:29 +00:00
|
|
|
okAction={createCandidate}
|
2023-03-24 10:23:44 +00:00
|
|
|
canSave={!loading &&
|
|
|
|
((object.firstName?.length ?? 0) > 0 || (object.lastName?.length ?? 0) > 0 || object.channels.length > 0)}
|
2022-02-02 09:03:29 +00:00
|
|
|
on:close={() => {
|
|
|
|
dispatch('close')
|
|
|
|
}}
|
2022-12-14 04:52:41 +00:00
|
|
|
onCancel={showConfirmationDialog}
|
2022-05-11 05:36:35 +00:00
|
|
|
bind:createMore
|
2022-02-02 09:03:29 +00:00
|
|
|
>
|
2022-06-16 14:30:26 +00:00
|
|
|
<svelte:fragment slot="header">
|
2022-05-11 05:36:35 +00:00
|
|
|
<Button
|
|
|
|
icon={contact.icon.Person}
|
|
|
|
label={contact.string.Person}
|
|
|
|
size={'small'}
|
|
|
|
kind={'no-border'}
|
|
|
|
disabled
|
|
|
|
on:click={() => {}}
|
|
|
|
/>
|
|
|
|
</svelte:fragment>
|
2022-04-17 04:05:10 +00:00
|
|
|
<div class="flex-between">
|
2021-09-10 06:41:22 +00:00
|
|
|
<div class="flex-col">
|
2022-04-29 05:27:17 +00:00
|
|
|
<EditBox
|
2022-11-03 08:13:25 +00:00
|
|
|
disabled={loading}
|
2022-04-29 05:27:17 +00:00
|
|
|
placeholder={recruit.string.PersonFirstNamePlaceholder}
|
2023-03-24 10:23:44 +00:00
|
|
|
bind:value={object.firstName}
|
2022-04-29 05:27:17 +00:00
|
|
|
kind={'large-style'}
|
|
|
|
focus
|
2022-10-05 06:41:02 +00:00
|
|
|
maxWidth={'30rem'}
|
2022-05-12 04:10:52 +00:00
|
|
|
focusIndex={1}
|
2022-04-29 05:27:17 +00:00
|
|
|
/>
|
|
|
|
<EditBox
|
2022-11-03 08:13:25 +00:00
|
|
|
disabled={loading}
|
2022-04-29 05:27:17 +00:00
|
|
|
placeholder={recruit.string.PersonLastNamePlaceholder}
|
2023-03-24 10:23:44 +00:00
|
|
|
bind:value={object.lastName}
|
2022-10-05 06:41:02 +00:00
|
|
|
maxWidth={'30rem'}
|
2022-04-29 05:27:17 +00:00
|
|
|
kind={'large-style'}
|
2022-05-12 04:10:52 +00:00
|
|
|
focusIndex={2}
|
2022-04-29 05:27:17 +00:00
|
|
|
/>
|
2022-04-13 04:25:59 +00:00
|
|
|
<div class="mt-1">
|
2022-10-05 06:41:02 +00:00
|
|
|
<EditBox
|
2022-11-03 08:13:25 +00:00
|
|
|
disabled={loading}
|
2022-10-05 06:41:02 +00:00
|
|
|
placeholder={recruit.string.Title}
|
|
|
|
bind:value={object.title}
|
|
|
|
kind={'small-style'}
|
|
|
|
focusIndex={3}
|
|
|
|
maxWidth={'30rem'}
|
|
|
|
/>
|
2022-02-25 13:23:50 +00:00
|
|
|
</div>
|
2022-10-05 06:41:02 +00:00
|
|
|
<EditBox
|
2022-11-03 08:13:25 +00:00
|
|
|
disabled={loading}
|
2022-10-05 06:41:02 +00:00
|
|
|
placeholder={recruit.string.Location}
|
|
|
|
bind:value={object.city}
|
|
|
|
kind={'small-style'}
|
|
|
|
focusIndex={4}
|
|
|
|
maxWidth={'30rem'}
|
|
|
|
/>
|
2021-09-10 06:41:22 +00:00
|
|
|
</div>
|
2022-04-17 04:05:10 +00:00
|
|
|
<div class="ml-4">
|
2022-04-29 05:27:17 +00:00
|
|
|
<EditableAvatar
|
2022-11-03 08:13:25 +00:00
|
|
|
disabled={loading}
|
2022-10-31 05:34:42 +00:00
|
|
|
bind:this={avatarEditor}
|
2023-03-24 10:23:44 +00:00
|
|
|
bind:direct={object.avatar}
|
|
|
|
avatar={undefined}
|
|
|
|
id={object._id}
|
2022-04-29 05:27:17 +00:00
|
|
|
size={'large'}
|
|
|
|
/>
|
2022-04-17 04:05:10 +00:00
|
|
|
</div>
|
2021-09-10 06:41:22 +00:00
|
|
|
</div>
|
2022-04-13 04:25:59 +00:00
|
|
|
<svelte:fragment slot="pool">
|
2022-12-07 05:02:03 +00:00
|
|
|
<ChannelsDropdown
|
|
|
|
editable={!loading}
|
|
|
|
focusIndex={10}
|
2023-03-24 10:23:44 +00:00
|
|
|
bind:value={object.channels}
|
2022-12-07 05:02:03 +00:00
|
|
|
highlighted={matchedChannels.map((it) => it.provider)}
|
|
|
|
/>
|
|
|
|
<YesNo
|
|
|
|
disabled={loading}
|
|
|
|
focusIndex={100}
|
|
|
|
label={recruit.string.Onsite}
|
|
|
|
tooltip={recruit.string.WorkLocationPreferences}
|
|
|
|
bind:value={object.onsite}
|
|
|
|
/>
|
|
|
|
<YesNo
|
|
|
|
disabled={loading}
|
|
|
|
focusIndex={101}
|
|
|
|
label={recruit.string.Remote}
|
|
|
|
tooltip={recruit.string.WorkLocationPreferences}
|
|
|
|
bind:value={object.remote}
|
|
|
|
/>
|
|
|
|
<Component
|
|
|
|
is={tags.component.TagsDropdownEditor}
|
|
|
|
props={{
|
|
|
|
disabled: loading,
|
|
|
|
focusIndex: 102,
|
2023-03-24 10:23:44 +00:00
|
|
|
items: object.skills,
|
2022-12-07 05:02:03 +00:00
|
|
|
key,
|
|
|
|
targetClass: recruit.mixin.Candidate,
|
|
|
|
showTitle: false,
|
|
|
|
elements,
|
|
|
|
newElements,
|
|
|
|
countLabel: recruit.string.NumberSkills
|
|
|
|
}}
|
|
|
|
on:open={(evt) => {
|
|
|
|
addTagRef(evt.detail)
|
|
|
|
}}
|
|
|
|
on:delete={(evt) => {
|
2023-03-24 10:23:44 +00:00
|
|
|
object.skills = object.skills.filter((it) => it._id !== evt.detail)
|
2022-12-07 05:02:03 +00:00
|
|
|
}}
|
|
|
|
/>
|
2023-03-24 10:23:44 +00:00
|
|
|
{#if object.skills.length > 0}
|
2022-12-07 07:21:39 +00:00
|
|
|
<div class="flex-break" />
|
|
|
|
<div class="antiComponent antiEmphasized flex-grow mt-2">
|
|
|
|
<Component
|
|
|
|
is={tags.component.TagsEditor}
|
|
|
|
props={{
|
|
|
|
disabled: loading,
|
|
|
|
focusIndex: 102,
|
2023-03-24 10:23:44 +00:00
|
|
|
items: object.skills,
|
2022-12-07 07:21:39 +00:00
|
|
|
key,
|
|
|
|
targetClass: recruit.mixin.Candidate,
|
|
|
|
showTitle: false,
|
|
|
|
elements,
|
|
|
|
newElements,
|
|
|
|
countLabel: recruit.string.NumberSkills
|
|
|
|
}}
|
|
|
|
on:open={(evt) => {
|
|
|
|
addTagRef(evt.detail)
|
|
|
|
}}
|
|
|
|
on:delete={(evt) => {
|
2023-03-24 10:23:44 +00:00
|
|
|
object.skills = object.skills.filter((it) => it._id !== evt.detail)
|
2022-12-07 07:21:39 +00:00
|
|
|
}}
|
|
|
|
on:change={(evt) => {
|
|
|
|
evt.detail.tag.weight = evt.detail.weight
|
2023-03-24 10:23:44 +00:00
|
|
|
object.skills = object.skills
|
2022-12-07 07:21:39 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-12-07 05:02:03 +00:00
|
|
|
{/if}
|
2023-03-17 15:57:36 +00:00
|
|
|
<div class="flex flex-grow flex-wrap">
|
|
|
|
<InlineAttributeBar
|
|
|
|
_class={recruit.mixin.Candidate}
|
|
|
|
{object}
|
|
|
|
toClass={contact.class.Contact}
|
2023-03-24 10:23:44 +00:00
|
|
|
{ignoreKeys}
|
2023-03-17 15:57:36 +00:00
|
|
|
extraProps={{ showNavigate: false }}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-04-13 04:25:59 +00:00
|
|
|
</svelte:fragment>
|
2022-11-29 15:22:33 +00:00
|
|
|
|
2022-04-13 04:25:59 +00:00
|
|
|
<svelte:fragment slot="footer">
|
2022-04-17 04:05:10 +00:00
|
|
|
<div
|
|
|
|
class="flex-center resume"
|
2023-03-24 10:23:44 +00:00
|
|
|
class:solid={dragover || object.resumeUuid}
|
2022-04-17 04:05:10 +00:00
|
|
|
on:dragover|preventDefault={() => {
|
|
|
|
dragover = true
|
|
|
|
}}
|
|
|
|
on:dragleave={() => {
|
|
|
|
dragover = false
|
|
|
|
}}
|
|
|
|
on:drop|preventDefault|stopPropagation={drop}
|
|
|
|
>
|
2023-03-24 10:23:44 +00:00
|
|
|
{#if loading && object.resumeUuid}
|
|
|
|
<Button label={recruit.string.Parsing} kind="link" icon={Spinner} disabled />
|
2022-04-17 04:05:10 +00:00
|
|
|
{:else}
|
|
|
|
{#if loading}
|
2023-03-24 10:23:44 +00:00
|
|
|
<Button label={recruit.string.Uploading} kind="link" icon={Spinner} disabled />
|
|
|
|
{:else if object.resumeUuid}
|
2022-11-03 08:13:25 +00:00
|
|
|
<Button
|
|
|
|
disabled={loading}
|
|
|
|
kind={'transparent'}
|
|
|
|
focusIndex={103}
|
|
|
|
icon={FileIcon}
|
|
|
|
on:click={() => {
|
2023-03-17 03:52:32 +00:00
|
|
|
showPopup(
|
|
|
|
PDFViewer,
|
2023-03-24 10:23:44 +00:00
|
|
|
{ file: object.resumeUuid, name: object.resumeName },
|
|
|
|
object.resumeType?.startsWith('image/') ? 'centered' : 'float'
|
2023-03-17 03:52:32 +00:00
|
|
|
)
|
2022-11-03 08:13:25 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<svelte:fragment slot="content">
|
2023-03-24 10:23:44 +00:00
|
|
|
<span class="overflow-label disabled">{object.resumeName}</span>
|
2022-11-03 08:13:25 +00:00
|
|
|
</svelte:fragment>
|
|
|
|
</Button>
|
2022-04-17 04:05:10 +00:00
|
|
|
{:else}
|
2022-05-12 04:10:52 +00:00
|
|
|
<Button
|
|
|
|
kind={'transparent'}
|
|
|
|
focusIndex={103}
|
|
|
|
label={recruit.string.AddDropHere}
|
2022-04-17 04:05:10 +00:00
|
|
|
icon={FileUpload}
|
|
|
|
on:click={() => {
|
|
|
|
inputFile.click()
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
<input bind:this={inputFile} type="file" name="file" id="file" style="display: none" on:change={fileSelected} />
|
|
|
|
{/if}
|
|
|
|
</div>
|
2022-04-13 04:25:59 +00:00
|
|
|
{#if matches.length > 0}
|
2022-05-16 20:06:57 +00:00
|
|
|
<div class="flex-col-stretch flex-grow error-color">
|
|
|
|
<div class="flex mb-1">
|
|
|
|
<IconInfo size={'medium'} />
|
|
|
|
<span class="text-sm overflow-label ml-2">
|
|
|
|
<Label label={contact.string.PersonAlreadyExists} />
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<PersonPresenter value={matches[0]} avatarSize={'tiny'} />
|
2022-04-13 04:25:59 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</svelte:fragment>
|
2021-09-10 06:41:22 +00:00
|
|
|
</Card>
|
2022-04-17 04:05:10 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.resume {
|
2022-12-07 05:02:03 +00:00
|
|
|
margin: -0.375rem 0rem -0.375rem -0.375rem;
|
|
|
|
padding: 0.375rem;
|
2022-04-17 04:05:10 +00:00
|
|
|
background: var(--accent-bg-color);
|
|
|
|
border: 1px dashed var(--divider-color);
|
2022-04-29 05:27:17 +00:00
|
|
|
border-radius: 0.5rem;
|
2022-04-17 04:05:10 +00:00
|
|
|
|
2022-04-29 05:27:17 +00:00
|
|
|
&.solid {
|
|
|
|
border-style: solid;
|
|
|
|
}
|
2022-04-17 04:05:10 +00:00
|
|
|
}
|
2022-11-29 15:22:33 +00:00
|
|
|
.skills-box {
|
|
|
|
padding: 0.5rem 0.75rem;
|
|
|
|
background: var(--accent-bg-color);
|
|
|
|
border: 1px dashed var(--divider-color);
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
}
|
2022-04-17 04:05:10 +00:00
|
|
|
</style>
|