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-14 09:24:14 +00:00
|
|
|
import core, { Ref } from '@anticrm/core'
|
|
|
|
import { EditBox, Grid, Dropdown } from '@anticrm/ui'
|
2021-11-02 08:45:08 +00:00
|
|
|
import { getClient, SpaceCreateCard } from '@anticrm/presentation'
|
2021-12-15 09:04:43 +00:00
|
|
|
import task, { KanbanTemplate, createKanban } from '@anticrm/task'
|
|
|
|
import { KanbanTemplateSelector } from '@anticrm/task-resources'
|
2021-12-14 09:24:14 +00:00
|
|
|
|
2021-11-02 08:45:08 +00:00
|
|
|
import Company from './icons/Company.svelte'
|
|
|
|
import Vacancy from './icons/Vacancy.svelte'
|
2021-08-07 17:03:06 +00:00
|
|
|
|
|
|
|
import recruit from '../plugin'
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
|
|
|
|
let name: string = ''
|
|
|
|
let description: string = ''
|
2021-12-14 09:24:14 +00:00
|
|
|
let templateId: Ref<KanbanTemplate> | undefined
|
2021-08-07 17:03:06 +00:00
|
|
|
|
2021-11-04 11:17:59 +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()
|
|
|
|
|
2021-09-05 12:03:33 +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}`)
|
|
|
|
}
|
|
|
|
|
2021-09-05 12:03:33 +00:00
|
|
|
const id = await client.createDoc(recruit.class.Vacancy, core.space.Model, {
|
2021-08-07 17:03:06 +00:00
|
|
|
name,
|
|
|
|
description,
|
|
|
|
private: false,
|
2021-12-21 09:08:22 +00:00
|
|
|
archived: false,
|
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>
|
|
|
|
|
2021-11-02 08:45:08 +00:00
|
|
|
<SpaceCreateCard
|
|
|
|
label={recruit.string.CreateVacancy}
|
|
|
|
okAction={createVacancy}
|
|
|
|
canSave={name ? true : false}
|
|
|
|
on:close={() => { dispatch('close') }}
|
|
|
|
>
|
|
|
|
<Grid column={1} rowGap={1.5}>
|
2021-12-17 09:06:08 +00:00
|
|
|
<EditBox label={recruit.string.VacancyName} bind:value={name} icon={Vacancy} placeholder="Software Engineer" maxWidth={'16rem'} focus/>
|
2021-11-03 14:59:24 +00:00
|
|
|
<Dropdown icon={Company} label={'Company *'} placeholder={'Company'} />
|
2021-12-14 09:24:14 +00:00
|
|
|
<KanbanTemplateSelector folders={[recruit.space.VacancyTemplates]} bind:template={templateId}/>
|
2021-11-02 08:45:08 +00:00
|
|
|
</Grid>
|
|
|
|
</SpaceCreateCard>
|