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-03-17 09:39:57 +00:00
|
|
|
import { Organization } from '@anticrm/contact'
|
2021-12-14 09:24:14 +00:00
|
|
|
import core, { Ref } from '@anticrm/core'
|
2022-04-13 04:25:59 +00:00
|
|
|
import { getClient, Card } from '@anticrm/presentation'
|
|
|
|
import task, { createKanban, KanbanTemplate } from '@anticrm/task'
|
|
|
|
import { Component, EditBox, Button } from '@anticrm/ui'
|
2022-02-09 09:08:09 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
import recruit from '../plugin'
|
2022-03-17 09:39:57 +00:00
|
|
|
import { OrganizationSelector } from '@anticrm/contact-resources'
|
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 = ''
|
2021-12-14 09:24:14 +00:00
|
|
|
let templateId: Ref<KanbanTemplate> | undefined
|
2022-03-17 09:39:57 +00:00
|
|
|
let company: Ref<Organization> | undefined
|
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 () {
|
2021-12-15 09:04:43 +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-03-17 05:05:30 +00:00
|
|
|
const id = await client.createDoc(recruit.class.Vacancy, core.space.Space, {
|
2021-08-07 17:03:06 +00:00
|
|
|
name,
|
|
|
|
description,
|
|
|
|
private: false,
|
2021-12-21 09:08:22 +00:00
|
|
|
archived: false,
|
2022-03-17 09:39:57 +00:00
|
|
|
company,
|
2021-12-02 09:09:37 +00:00
|
|
|
members: []
|
2021-08-07 17:03:06 +00:00
|
|
|
})
|
2021-12-14 09:24:14 +00:00
|
|
|
|
|
|
|
await createKanban(client, id, templateId)
|
2021-08-07 17:03:06 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-04-13 04:25:59 +00:00
|
|
|
<Card
|
2021-11-02 08:45:08 +00:00
|
|
|
label={recruit.string.CreateVacancy}
|
|
|
|
okAction={createVacancy}
|
2022-02-09 09:08:09 +00:00
|
|
|
canSave={!!name}
|
2021-11-02 08:45:08 +00:00
|
|
|
on:close={() => { dispatch('close') }}
|
|
|
|
>
|
2022-04-13 04:25:59 +00:00
|
|
|
<div class="flex-row-center clear-mins">
|
|
|
|
<div class="mr-3">
|
|
|
|
<Button icon={Vacancy} size={'medium'} kind={'link-bordered'} disabled />
|
|
|
|
</div>
|
|
|
|
<EditBox
|
|
|
|
bind:value={name}
|
|
|
|
placeholder={recruit.string.VacancyPlaceholder}
|
|
|
|
maxWidth={'37.5rem'} kind={'large-style'} focus
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<svelte:fragment slot="pool">
|
2022-04-09 03:46:40 +00:00
|
|
|
<OrganizationSelector
|
|
|
|
bind:value={company} label={recruit.string.Company}
|
2022-04-13 04:25:59 +00:00
|
|
|
kind={'no-border'} size={'small'}
|
2022-04-09 03:46:40 +00:00
|
|
|
/>
|
2022-02-09 09:08:09 +00:00
|
|
|
<Component is={task.component.KanbanTemplateSelector} props={{
|
|
|
|
folders: [recruit.space.VacancyTemplates],
|
|
|
|
template: templateId
|
|
|
|
}} on:change={(evt) => {
|
|
|
|
templateId = evt.detail
|
|
|
|
}}/>
|
2022-04-13 04:25:59 +00:00
|
|
|
</svelte:fragment>
|
|
|
|
</Card>
|