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-12-10 09:46:08 +00:00
|
|
|
import { getCurrentAccount, Ref, Space } from '@anticrm/core'
|
2021-12-08 09:24:24 +00:00
|
|
|
import { CircleButton, EditBox, showPopup, IconAdd, Label, AnyComponent, IconActivity } from '@anticrm/ui'
|
2021-12-06 10:07:08 +00:00
|
|
|
import { getClient, createQuery, Channels, AttributeEditor, AttributesBar, Avatar } from '@anticrm/presentation'
|
2021-09-11 19:09:39 +00:00
|
|
|
import { Panel } from '@anticrm/panel'
|
2021-09-15 17:51:22 +00:00
|
|
|
import type { Candidate } from '@anticrm/recruit'
|
2021-09-11 18:33:51 +00:00
|
|
|
import Contact from './icons/Contact.svelte'
|
2021-09-12 22:01:18 +00:00
|
|
|
import Edit from './icons/Edit.svelte'
|
2021-11-29 17:19:33 +00:00
|
|
|
import Applications from './Applications.svelte'
|
2021-12-07 09:05:52 +00:00
|
|
|
import { Attachments } from '@anticrm/attachment-resources'
|
2021-11-25 11:05:00 +00:00
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
import recruit from '../plugin'
|
2021-12-10 09:46:08 +00:00
|
|
|
import setting from '@anticrm/setting'
|
|
|
|
import { IntegrationType } from '@anticrm/setting'
|
2021-12-06 10:07:08 +00:00
|
|
|
import contact, { combineName, formatName, getFirstName, getLastName } from '@anticrm/contact'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
export let _id: Ref<Candidate>
|
|
|
|
let object: Candidate
|
2021-11-25 11:05:00 +00:00
|
|
|
let rightSection: AnyComponent | undefined
|
|
|
|
let fullSize: boolean = false
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-10-01 12:28:52 +00:00
|
|
|
let firstName = ''
|
|
|
|
let lastName = ''
|
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
const client = getClient()
|
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
const query = createQuery()
|
2021-12-10 09:46:08 +00:00
|
|
|
$: query.query(recruit.class.Candidate, { _id }, (result) => {
|
|
|
|
object = result[0]
|
|
|
|
firstName = getFirstName(result[0].name)
|
|
|
|
lastName = getLastName(result[0].name)
|
|
|
|
})
|
2021-09-15 17:03:34 +00:00
|
|
|
|
2021-09-12 14:47:49 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
2021-09-12 06:45:16 +00:00
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
function saveChannels (result: any) {
|
2021-11-23 13:59:41 +00:00
|
|
|
if (result !== undefined) {
|
|
|
|
object.channels = result
|
|
|
|
client.updateDoc(recruit.class.Candidate, object.space, object._id, { channels: result })
|
|
|
|
}
|
2021-09-12 22:01:18 +00:00
|
|
|
}
|
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
function firstNameChange () {
|
|
|
|
client.updateDoc(recruit.class.Candidate, object.space, object._id, {
|
|
|
|
name: combineName(firstName, getLastName(object.name))
|
|
|
|
})
|
2021-10-01 12:28:52 +00:00
|
|
|
}
|
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
function lastNameChange () {
|
|
|
|
client.updateDoc(recruit.class.Candidate, object.space, object._id, {
|
|
|
|
name: combineName(getFirstName(object.name), lastName)
|
|
|
|
})
|
2021-10-01 12:28:52 +00:00
|
|
|
}
|
2021-12-08 09:24:24 +00:00
|
|
|
|
|
|
|
const openActivity = (): void => {
|
|
|
|
rightSection = undefined
|
|
|
|
fullSize = true
|
|
|
|
}
|
2021-12-10 09:46:08 +00:00
|
|
|
|
|
|
|
const accountId = getCurrentAccount()._id
|
|
|
|
let integrations: Set<Ref<IntegrationType>> = new Set<Ref<IntegrationType>>()
|
|
|
|
const settingsQuery = createQuery()
|
|
|
|
$: settingsQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space> }, (res) => {
|
|
|
|
integrations = new Set(res.map((p) => p.type))
|
|
|
|
})
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
{#if object !== undefined}
|
2021-12-10 09:46:08 +00:00
|
|
|
<Panel
|
|
|
|
icon={Contact}
|
|
|
|
title={formatName(object.name)}
|
|
|
|
{rightSection}
|
|
|
|
{fullSize}
|
|
|
|
{object}
|
|
|
|
on:close={() => {
|
|
|
|
dispatch('close')
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<AttributesBar {object} keys={['city', 'onsite', 'remote', 'source']} slot="subtitle" />
|
|
|
|
|
|
|
|
<div class="flex-row-center">
|
|
|
|
<div class="mr-8">
|
|
|
|
<Avatar avatar={object.avatar} size={'x-large'} />
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow flex-col">
|
|
|
|
<div class="name">
|
|
|
|
<EditBox placeholder="John" maxWidth="20rem" bind:value={firstName} on:change={firstNameChange} />
|
|
|
|
</div>
|
|
|
|
<div class="name">
|
|
|
|
<EditBox placeholder="Appleseed" maxWidth="20rem" bind:value={lastName} on:change={lastNameChange} />
|
|
|
|
</div>
|
|
|
|
<div class="title">
|
|
|
|
<AttributeEditor maxWidth="20rem" _class={recruit.class.Candidate} {object} key="title" />
|
2021-12-08 09:24:24 +00:00
|
|
|
</div>
|
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
<div class="separator" />
|
|
|
|
|
|
|
|
<div class="flex-between">
|
|
|
|
<div class="flex-row-center">
|
|
|
|
{#if !object.channels || object.channels.length === 0}
|
|
|
|
<CircleButton
|
|
|
|
icon={IconAdd}
|
|
|
|
size={'small'}
|
|
|
|
selected
|
|
|
|
on:click={(ev) =>
|
|
|
|
showPopup(contact.component.SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => {
|
|
|
|
saveChannels(result)
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<span class="ml-2"><Label label={'Add social links'} /></span>
|
|
|
|
{:else}
|
|
|
|
<Channels
|
|
|
|
value={object.channels}
|
|
|
|
{integrations}
|
|
|
|
size={'small'}
|
|
|
|
on:click={(ev) => {
|
|
|
|
if (ev.detail.presenter) {
|
|
|
|
fullSize = true
|
|
|
|
rightSection = ev.detail.presenter
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<div class="ml-1">
|
|
|
|
<CircleButton
|
|
|
|
icon={Edit}
|
|
|
|
size={'small'}
|
|
|
|
on:click={(ev) =>
|
|
|
|
showPopup(
|
|
|
|
contact.component.SocialEditor,
|
|
|
|
{ values: object.channels ?? [] },
|
|
|
|
ev.target,
|
|
|
|
(result) => {
|
|
|
|
saveChannels(result)
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex-row-center">
|
|
|
|
<a href={'#'} class="flex-row-center" on:click={openActivity}>
|
|
|
|
<CircleButton icon={IconActivity} size={'small'} primary on:click={openActivity} />
|
|
|
|
<span class="ml-2 small-text">View activity</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-12-08 09:24:24 +00:00
|
|
|
</div>
|
2021-10-04 17:31:12 +00:00
|
|
|
</div>
|
2021-09-12 06:45:16 +00:00
|
|
|
</div>
|
2021-10-13 08:38:35 +00:00
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
<div class="mt-14">
|
|
|
|
<Applications objectId={object._id} _class={object._class} space={object.space} />
|
|
|
|
</div>
|
2021-12-15 09:04:43 +00:00
|
|
|
|
2021-12-10 09:46:08 +00:00
|
|
|
<div class="mt-14">
|
|
|
|
<Attachments
|
|
|
|
objectId={object._id}
|
|
|
|
_class={object._class}
|
|
|
|
space={object.space}
|
|
|
|
noLabel={recruit.string.NoAttachmentsForCandidate}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Panel>
|
2021-09-15 17:03:34 +00:00
|
|
|
{/if}
|
2021-08-30 13:37:49 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
2021-09-12 06:45:16 +00:00
|
|
|
.name {
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 1.25rem;
|
|
|
|
color: var(--theme-caption-color);
|
|
|
|
}
|
2021-10-04 17:31:12 +00:00
|
|
|
.title {
|
2021-12-10 09:46:08 +00:00
|
|
|
margin-top: 0.25rem;
|
|
|
|
font-size: 0.75rem;
|
2021-09-12 06:45:16 +00:00
|
|
|
}
|
2021-12-08 09:24:24 +00:00
|
|
|
.separator {
|
|
|
|
margin: 1rem 0;
|
|
|
|
height: 1px;
|
|
|
|
background-color: var(--theme-card-divider);
|
2021-09-12 06:45:16 +00:00
|
|
|
}
|
2021-08-30 13:37:49 +00:00
|
|
|
</style>
|