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-10-05 06:41:02 +00:00
|
|
|
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
|
2022-09-21 08:08:25 +00:00
|
|
|
import contact, { Organization } from '@hcengineering/contact'
|
2022-10-05 06:41:02 +00:00
|
|
|
import core, { generateId, getCurrentAccount, Ref } from '@hcengineering/core'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { Card, getClient, UserBox } from '@hcengineering/presentation'
|
|
|
|
import task, { createKanban, KanbanTemplate } from '@hcengineering/task'
|
2022-10-05 06:41:02 +00:00
|
|
|
import { Button, Component, createFocusManager, EditBox, FocusHandler, IconAttachment } from '@hcengineering/ui'
|
2022-02-09 09:08:09 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
import recruit from '../plugin'
|
2022-10-05 06:41:02 +00:00
|
|
|
import { Vacancy as VacancyClass } from '@hcengineering/recruit'
|
2022-05-16 11:41:22 +00:00
|
|
|
import Company from './icons/Company.svelte'
|
2021-11-02 08:45:08 +00:00
|
|
|
import Vacancy from './icons/Vacancy.svelte'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
|
|
|
|
let name: string = ''
|
2022-02-09 09:08:09 +00:00
|
|
|
const description: string = ''
|
2022-10-05 06:41:02 +00:00
|
|
|
let fullDescription: string = ''
|
2021-12-14 09:24:14 +00:00
|
|
|
let templateId: Ref<KanbanTemplate> | undefined
|
2022-10-05 06:41:02 +00:00
|
|
|
let objectId: Ref<VacancyClass> = generateId()
|
|
|
|
|
2022-09-14 04:53:48 +00:00
|
|
|
export let company: Ref<Organization> | undefined
|
|
|
|
export let preserveCompany: boolean = false
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2022-02-09 09:08:09 +00:00
|
|
|
export function canClose (): boolean {
|
2021-12-21 09:42:18 +00:00
|
|
|
return name === '' && templateId !== undefined
|
2021-11-04 11:17:59 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
const client = getClient()
|
|
|
|
|
2022-02-09 09:08:09 +00:00
|
|
|
async function createVacancy () {
|
2022-04-29 05:27:17 +00:00
|
|
|
if (
|
|
|
|
templateId !== undefined &&
|
|
|
|
(await client.findOne(task.class.KanbanTemplate, { _id: templateId })) === undefined
|
|
|
|
) {
|
2021-12-14 09:24:14 +00:00
|
|
|
throw Error(`Failed to find target kanban template: ${templateId}`)
|
|
|
|
}
|
|
|
|
|
2022-10-05 06:41:02 +00:00
|
|
|
const id = await client.createDoc(
|
|
|
|
recruit.class.Vacancy,
|
|
|
|
core.space.Space,
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
description,
|
|
|
|
fullDescription,
|
|
|
|
private: false,
|
|
|
|
archived: false,
|
|
|
|
company,
|
|
|
|
members: [getCurrentAccount()._id]
|
|
|
|
},
|
|
|
|
objectId
|
|
|
|
)
|
2021-12-14 09:24:14 +00:00
|
|
|
|
|
|
|
await createKanban(client, id, templateId)
|
2022-10-05 06:41:02 +00:00
|
|
|
|
|
|
|
await descriptionBox.createAttachments()
|
|
|
|
objectId = generateId()
|
|
|
|
|
2022-05-16 11:41:22 +00:00
|
|
|
dispatch('close', id)
|
2021-08-07 17:03:06 +00:00
|
|
|
}
|
2022-05-16 11:41:22 +00:00
|
|
|
const manager = createFocusManager()
|
2022-10-05 06:41:02 +00:00
|
|
|
|
|
|
|
let descriptionBox: AttachmentStyledBox
|
2021-08-07 17:03:06 +00:00
|
|
|
</script>
|
|
|
|
|
2022-05-16 11:41:22 +00:00
|
|
|
<FocusHandler {manager} />
|
2022-04-29 05:27:17 +00:00
|
|
|
<Card
|
|
|
|
label={recruit.string.CreateVacancy}
|
2021-11-02 08:45:08 +00:00
|
|
|
okAction={createVacancy}
|
2022-02-09 09:08:09 +00:00
|
|
|
canSave={!!name}
|
2022-04-29 05:27:17 +00:00
|
|
|
on:close={() => {
|
|
|
|
dispatch('close')
|
|
|
|
}}
|
2021-11-02 08:45:08 +00:00
|
|
|
>
|
2022-04-13 04:25:59 +00:00
|
|
|
<div class="flex-row-center clear-mins">
|
|
|
|
<div class="mr-3">
|
2022-05-16 11:41:22 +00:00
|
|
|
<Button focusIndex={1} icon={Vacancy} size={'medium'} kind={'link-bordered'} disabled />
|
2022-04-13 04:25:59 +00:00
|
|
|
</div>
|
2022-10-04 15:49:11 +00:00
|
|
|
<div class="clear-mins flex-grow">
|
|
|
|
<EditBox
|
|
|
|
focusIndex={2}
|
|
|
|
bind:value={name}
|
|
|
|
placeholder={recruit.string.VacancyPlaceholder}
|
|
|
|
kind={'large-style'}
|
|
|
|
focus
|
|
|
|
/>
|
|
|
|
</div>
|
2022-04-13 04:25:59 +00:00
|
|
|
</div>
|
2022-10-05 06:41:02 +00:00
|
|
|
<svelte:fragment slot="header">
|
2022-05-16 11:41:22 +00:00
|
|
|
<UserBox
|
|
|
|
focusIndex={3}
|
|
|
|
_class={contact.class.Organization}
|
|
|
|
label={recruit.string.Company}
|
|
|
|
placeholder={recruit.string.Company}
|
2022-09-14 04:53:48 +00:00
|
|
|
justify={'left'}
|
2022-05-16 11:41:22 +00:00
|
|
|
bind:value={company}
|
|
|
|
allowDeselect
|
|
|
|
titleDeselect={recruit.string.UnAssignCompany}
|
|
|
|
kind={'no-border'}
|
|
|
|
size={'small'}
|
|
|
|
icon={Company}
|
2022-09-14 04:53:48 +00:00
|
|
|
readonly={preserveCompany}
|
|
|
|
showNavigate={false}
|
2022-05-16 11:41:22 +00:00
|
|
|
create={{ component: contact.component.CreateOrganization, label: contact.string.CreateOrganization }}
|
|
|
|
/>
|
2022-10-05 06:41:02 +00:00
|
|
|
</svelte:fragment>
|
|
|
|
|
|
|
|
<AttachmentStyledBox
|
|
|
|
bind:this={descriptionBox}
|
|
|
|
{objectId}
|
|
|
|
_class={recruit.class.Vacancy}
|
|
|
|
space={objectId}
|
|
|
|
alwaysEdit
|
|
|
|
showButtons={false}
|
|
|
|
maxHeight={'card'}
|
|
|
|
bind:content={fullDescription}
|
|
|
|
placeholder={recruit.string.FullDescription}
|
|
|
|
/>
|
|
|
|
<svelte:fragment slot="pool">
|
2022-04-29 05:27:17 +00:00
|
|
|
<Component
|
|
|
|
is={task.component.KanbanTemplateSelector}
|
|
|
|
props={{
|
|
|
|
folders: [recruit.space.VacancyTemplates],
|
2022-05-16 11:41:22 +00:00
|
|
|
template: templateId,
|
|
|
|
focusIndex: 4
|
2022-04-29 05:27:17 +00:00
|
|
|
}}
|
|
|
|
on:change={(evt) => {
|
|
|
|
templateId = evt.detail
|
|
|
|
}}
|
2022-04-09 03:46:40 +00:00
|
|
|
/>
|
2022-04-13 04:25:59 +00:00
|
|
|
</svelte:fragment>
|
2022-10-05 06:41:02 +00:00
|
|
|
<svelte:fragment slot="footer">
|
|
|
|
<Button
|
|
|
|
icon={IconAttachment}
|
|
|
|
kind={'transparent'}
|
|
|
|
on:click={() => {
|
|
|
|
descriptionBox.attach()
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</svelte:fragment>
|
2022-04-13 04:25:59 +00:00
|
|
|
</Card>
|