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-06 10:07:08 +00:00
|
|
|
import type { Ref } from '@anticrm/core'
|
2021-12-07 09:05:52 +00:00
|
|
|
import { CircleButton, EditBox, showPopup, IconAdd, Label, AnyComponent } 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-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-10-01 12:28:52 +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-09-12 22:01:18 +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-10-01 12:28:52 +00:00
|
|
|
function firstNameChange() {
|
|
|
|
client.updateDoc(recruit.class.Candidate, object.space, object._id, { name: combineName(firstName, getLastName(object.name)) })
|
|
|
|
}
|
|
|
|
|
|
|
|
function lastNameChange() {
|
|
|
|
client.updateDoc(recruit.class.Candidate, object.space, object._id, { name: combineName(getFirstName(object.name), lastName) })
|
|
|
|
}
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-15 17:03:34 +00:00
|
|
|
{#if object !== undefined}
|
2021-11-25 11:05:00 +00:00
|
|
|
<Panel icon={Contact} title={formatName(object.name)} {rightSection} {fullSize} {object} on:close={() => { dispatch('close') }}>
|
2021-11-25 11:18:31 +00:00
|
|
|
<AttributesBar {object} keys={['city', 'onsite', 'remote', 'source']} slot="subtitle" />
|
2021-09-12 06:45:16 +00:00
|
|
|
|
2021-09-12 16:06:39 +00:00
|
|
|
<div class="flex-row-center">
|
2021-11-10 20:10:11 +00:00
|
|
|
<div class="mr-8">
|
|
|
|
<Avatar avatar={object.avatar} size={'x-large'} />
|
2021-09-12 06:45:16 +00:00
|
|
|
</div>
|
|
|
|
<div class="flex-col">
|
2021-10-01 12:28:52 +00:00
|
|
|
<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>
|
2021-09-28 12:09:43 +00:00
|
|
|
<div class="title"><AttributeEditor maxWidth="20rem" _class={recruit.class.Candidate} {object} key="title"/></div>
|
2021-10-04 15:08:08 +00:00
|
|
|
<!-- <div class="city"><AttributeEditor maxWidth="20rem" _class={recruit.class.Candidate} {object} key="city"/></div> -->
|
2021-10-04 17:31:12 +00:00
|
|
|
<div class="flex-row-center channels">
|
|
|
|
{#if !object.channels || object.channels.length === 0}
|
2021-12-06 10:07:08 +00:00
|
|
|
<CircleButton icon={IconAdd} size={'small'} selected on:click={(ev) => showPopup(contact.component.SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { saveChannels(result) })} />
|
2021-10-04 17:31:12 +00:00
|
|
|
<span><Label label={'Add social links'} /></span>
|
|
|
|
{:else}
|
2021-11-25 11:05:00 +00:00
|
|
|
<Channels value={object.channels} size={'small'} on:click={(ev) => {
|
|
|
|
if (ev.detail.presenter) {
|
|
|
|
fullSize = true
|
|
|
|
rightSection = ev.detail.presenter
|
|
|
|
}
|
|
|
|
}} />
|
2021-11-25 11:09:37 +00:00
|
|
|
<div class="ml-1">
|
2021-12-06 10:07:08 +00:00
|
|
|
<CircleButton icon={Edit} size={'small'} selected on:click={(ev) => showPopup(contact.component.SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => { saveChannels(result) })} />
|
2021-11-25 11:09:37 +00:00
|
|
|
</div>
|
2021-10-04 17:31:12 +00:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-09-12 06:45:16 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-11-29 17:19:33 +00:00
|
|
|
<div class="mt-14">
|
|
|
|
<Applications objectId={object._id} _class={object._class} space={object.space} />
|
2021-10-23 14:49:11 +00:00
|
|
|
</div>
|
2021-10-13 08:38:35 +00:00
|
|
|
|
2021-11-29 17:19:33 +00:00
|
|
|
<div class="mt-14">
|
2021-12-07 09:05:52 +00:00
|
|
|
<Attachments objectId={object._id} _class={object._class} space={object.space} noLabel={recruit.string.NoAttachmentsForCandidate} />
|
2021-09-12 06:45:16 +00:00
|
|
|
</div>
|
2021-09-11 18:33:51 +00:00
|
|
|
|
|
|
|
</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 {
|
|
|
|
margin-top: .25rem;
|
2021-09-12 06:45:16 +00:00
|
|
|
font-size: .75rem;
|
|
|
|
}
|
2021-10-04 17:31:12 +00:00
|
|
|
.channels {
|
|
|
|
margin-top: .75rem;
|
|
|
|
span { margin-left: .5rem; }
|
2021-09-12 06:45:16 +00:00
|
|
|
}
|
2021-08-30 13:37:49 +00:00
|
|
|
</style>
|