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">
|
2021-12-14 09:24:14 +00:00
|
|
|
import core, { Ref } from '@anticrm/core'
|
2021-11-02 08:45:08 +00:00
|
|
|
import { getClient, SpaceCreateCard } from '@anticrm/presentation'
|
2022-02-09 09:08:09 +00:00
|
|
|
import task, { createKanban, KanbanTemplate } from '@anticrm/task'
|
|
|
|
import { Component, Dropdown, EditBox, Grid } from '@anticrm/ui'
|
|
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
import recruit from '../plugin'
|
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
|
|
|
|
|
|
|
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
|
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,
|
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}
|
2022-02-09 09:08:09 +00:00
|
|
|
canSave={!!name}
|
2021-11-02 08:45:08 +00:00
|
|
|
on:close={() => { dispatch('close') }}
|
|
|
|
>
|
|
|
|
<Grid column={1} rowGap={1.5}>
|
2022-02-23 16:10:11 +00:00
|
|
|
<EditBox label={recruit.string.VacancyName} bind:value={name} icon={Vacancy} placeholder={recruit.string.VacancyPlaceholder} maxWidth={'16rem'} focus/>
|
2022-01-12 09:18:50 +00:00
|
|
|
<Dropdown icon={Company} label={recruit.string.Company} placeholder={'Company'} />
|
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
|
|
|
|
}}/>
|
2021-11-02 08:45:08 +00:00
|
|
|
</Grid>
|
|
|
|
</SpaceCreateCard>
|