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'
|
|
|
|
import type { Ref, Space } from '@anticrm/core'
|
2021-09-08 16:16:07 +00:00
|
|
|
import { DatePicker, EditBox, Tabs, Section, Grid, Row, Button, IconFile } from '@anticrm/ui'
|
|
|
|
import { UserBox, Card, UserInfo, Avatar } from '@anticrm/presentation'
|
2021-09-06 08:30:31 +00:00
|
|
|
import type { Employee, Person } from '@anticrm/contact'
|
2021-08-07 17:03:06 +00:00
|
|
|
import Address from './icons/Address.svelte'
|
|
|
|
import Attachment from './icons/Attachment.svelte'
|
|
|
|
|
|
|
|
import { getClient } from '@anticrm/presentation'
|
|
|
|
|
2021-09-05 12:03:33 +00:00
|
|
|
import core from '@anticrm/core'
|
2021-08-07 17:03:06 +00:00
|
|
|
import recruit from '../plugin'
|
2021-09-06 08:30:31 +00:00
|
|
|
import contact from '@anticrm/contact'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
export let space: Ref<Space>
|
2021-09-09 14:11:02 +00:00
|
|
|
export let candidate: Ref<Person> // | null = null
|
|
|
|
export let employee: Ref<Employee> // | null = null
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-09-08 15:36:04 +00:00
|
|
|
export let preserveCandidate = false
|
|
|
|
|
2021-09-09 07:54:52 +00:00
|
|
|
let _space = space
|
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const client = getClient()
|
|
|
|
|
2021-09-06 11:28:30 +00:00
|
|
|
async function createApplication() {
|
2021-09-09 07:54:52 +00:00
|
|
|
const state = await client.findOne(core.class.State, { space: _space })
|
2021-09-06 11:28:30 +00:00
|
|
|
if (state === undefined) {
|
|
|
|
throw new Error('create application: state not found')
|
|
|
|
}
|
2021-09-09 07:54:52 +00:00
|
|
|
await client.createDoc(recruit.class.Applicant, _space, {
|
2021-08-07 17:03:06 +00:00
|
|
|
candidate,
|
2021-09-06 11:28:30 +00:00
|
|
|
state: state._id
|
2021-08-07 17:03:06 +00:00
|
|
|
})
|
2021-09-03 09:41:21 +00:00
|
|
|
dispatch('close')
|
2021-08-07 17:03:06 +00:00
|
|
|
}
|
2021-09-03 09:41:21 +00:00
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-03 13:59:05 +00:00
|
|
|
<Card label={'Create Application'}
|
2021-09-07 12:18:19 +00:00
|
|
|
okLabel={'Save'}
|
2021-09-06 11:28:30 +00:00
|
|
|
okAction={createApplication}
|
2021-09-07 12:18:19 +00:00
|
|
|
canSave={candidate !== undefined}
|
2021-09-08 16:16:07 +00:00
|
|
|
spaceClass={recruit.class.Vacancy}
|
2021-09-11 06:38:54 +00:00
|
|
|
spaceLabel={'Vacancy'}
|
|
|
|
spacePlaceholder={'Select vacancy'}
|
2021-09-09 07:54:52 +00:00
|
|
|
bind:space={_space}
|
2021-09-03 13:59:05 +00:00
|
|
|
on:close={() => { dispatch('close') }}>
|
2021-09-03 15:39:10 +00:00
|
|
|
<Grid column={1} rowGap={1.75}>
|
2021-09-08 15:36:04 +00:00
|
|
|
{#if !preserveCandidate}
|
|
|
|
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} />
|
|
|
|
{/if}
|
2021-09-06 08:30:31 +00:00
|
|
|
<UserBox _class={contact.class.Employee} title='Assigned recruiter' caption='Recruiters' bind:value={employee} />
|
2021-09-03 13:59:05 +00:00
|
|
|
</Grid>
|
|
|
|
</Card>
|