mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-17 05:47:32 +00:00
create application validation
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
3367f222ea
commit
e28190ca52
plugins/recruit-resources/src
@ -16,9 +16,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import type { Ref, Space } from '@anticrm/core'
|
import type { Ref, Space } from '@anticrm/core'
|
||||||
import { DatePicker, EditBox, Tabs, Section, Grid, Row, Button, IconFile } from '@anticrm/ui'
|
import { Status, OK, Severity } from '@anticrm/platform'
|
||||||
|
import { DatePicker, EditBox, Tabs, Section, Grid, StatusControl } from '@anticrm/ui'
|
||||||
import { UserBox, Card, UserInfo, Avatar } from '@anticrm/presentation'
|
import { UserBox, Card, UserInfo, Avatar } from '@anticrm/presentation'
|
||||||
import type { Employee, Person } from '@anticrm/contact'
|
import type { Employee, Person } from '@anticrm/contact'
|
||||||
|
import type { Candidate } from '@anticrm/recruit'
|
||||||
import Address from './icons/Address.svelte'
|
import Address from './icons/Address.svelte'
|
||||||
import Attachment from './icons/Attachment.svelte'
|
import Attachment from './icons/Attachment.svelte'
|
||||||
|
|
||||||
@ -29,11 +31,12 @@
|
|||||||
import contact from '@anticrm/contact'
|
import contact from '@anticrm/contact'
|
||||||
|
|
||||||
export let space: Ref<Space>
|
export let space: Ref<Space>
|
||||||
export let candidate: Ref<Person> // | null = null
|
export let candidate: Ref<Candidate> // | null = null
|
||||||
export let employee: Ref<Employee> // | null = null
|
export let employee: Ref<Employee> // | null = null
|
||||||
|
|
||||||
export let preserveCandidate = false
|
export let preserveCandidate = false
|
||||||
|
|
||||||
|
let status: Status = OK
|
||||||
let _space = space
|
let _space = space
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
@ -51,17 +54,37 @@
|
|||||||
dispatch('close')
|
dispatch('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function validate(candidate: Ref<Candidate>, space: Ref<Space>) {
|
||||||
|
if (candidate === undefined) {
|
||||||
|
status = new Status(Severity.INFO, recruit.status.CandidateRequired, {})
|
||||||
|
} else {
|
||||||
|
if (space === undefined) {
|
||||||
|
status = new Status(Severity.INFO, recruit.status.VacancyRequired, {})
|
||||||
|
} else {
|
||||||
|
const applicants = await client.findAll(recruit.class.Applicant, { space, candidate})
|
||||||
|
if (applicants.length > 0) {
|
||||||
|
status = new Status(Severity.ERROR, recruit.status.ApplicationExists, {})
|
||||||
|
} else {
|
||||||
|
status = OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: validate(candidate, _space)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card label={'Create Application'}
|
<Card label={'Create Application'}
|
||||||
okLabel={'Save'}
|
okLabel={'Save'}
|
||||||
okAction={createApplication}
|
okAction={createApplication}
|
||||||
canSave={candidate !== undefined}
|
canSave={status.severity === Severity.OK}
|
||||||
spaceClass={recruit.class.Vacancy}
|
spaceClass={recruit.class.Vacancy}
|
||||||
spaceLabel={'Vacancy'}
|
spaceLabel={'Vacancy'}
|
||||||
spacePlaceholder={'Select vacancy'}
|
spacePlaceholder={'Select vacancy'}
|
||||||
bind:space={_space}
|
bind:space={_space}
|
||||||
on:close={() => { dispatch('close') }}>
|
on:close={() => { dispatch('close') }}>
|
||||||
|
<StatusControl {status}/>
|
||||||
<Grid column={1} rowGap={1.75}>
|
<Grid column={1} rowGap={1.75}>
|
||||||
{#if !preserveCandidate}
|
{#if !preserveCandidate}
|
||||||
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} />
|
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} />
|
||||||
|
@ -14,13 +14,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { mergeIds } from '@anticrm/platform'
|
import { mergeIds } from '@anticrm/platform'
|
||||||
import type { IntlString } from '@anticrm/platform'
|
import type { IntlString, StatusCode } from '@anticrm/platform'
|
||||||
import type { Ref, Class } from '@anticrm/core'
|
import type { Ref, Class } from '@anticrm/core'
|
||||||
import type { AnyComponent } from '@anticrm/ui'
|
import type { AnyComponent } from '@anticrm/ui'
|
||||||
import type { Applicant, Candidate, Candidates, Vacancy } from '@anticrm/recruit'
|
import type { Applicant, Candidate, Candidates, Vacancy } from '@anticrm/recruit'
|
||||||
import recruit, { recruitId } from '@anticrm/recruit'
|
import recruit, { recruitId } from '@anticrm/recruit'
|
||||||
|
|
||||||
export default mergeIds(recruitId, recruit, {
|
export default mergeIds(recruitId, recruit, {
|
||||||
|
status: {
|
||||||
|
ApplicationExists: '' as StatusCode,
|
||||||
|
CandidateRequired: '' as StatusCode,
|
||||||
|
VacancyRequired: '' as StatusCode,
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
Vacancy: '' as Ref<Class<Vacancy>>,
|
Vacancy: '' as Ref<Class<Vacancy>>,
|
||||||
Candidates: '' as Ref<Class<Candidates>>,
|
Candidates: '' as Ref<Class<Candidates>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user