userbox fixes and preserve candidate

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-08 17:36:04 +02:00
parent 6dd4084b61
commit c265bf64cf
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
4 changed files with 19 additions and 4 deletions

View File

@ -24,6 +24,7 @@
"@anticrm/query": "~0.6.1", "@anticrm/query": "~0.6.1",
"@anticrm/ui": "~0.6.0", "@anticrm/ui": "~0.6.0",
"@anticrm/view": "~0.6.0", "@anticrm/view": "~0.6.0",
"svelte": "^3.37.0" "svelte": "^3.37.0",
"@anticrm/contact": "~0.6.0"
} }
} }

View File

@ -15,6 +15,7 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte' import { onMount } from 'svelte'
import type { IntlString } from '@anticrm/platform' import type { IntlString } from '@anticrm/platform'
import { getClient } from '../utils'
import { Label, showPopup } from '@anticrm/ui' import { Label, showPopup } from '@anticrm/ui'
import Avatar from './Avatar.svelte' import Avatar from './Avatar.svelte'
@ -25,6 +26,8 @@
import type { Ref, Class } from '@anticrm/core' import type { Ref, Class } from '@anticrm/core'
import type { Person } from '@anticrm/contact' import type { Person } from '@anticrm/contact'
import contact from '@anticrm/contact'
export let _class: Ref<Class<Person>> export let _class: Ref<Class<Person>>
export let title: IntlString export let title: IntlString
export let caption: IntlString export let caption: IntlString
@ -34,6 +37,14 @@
let selected: Person | undefined let selected: Person | undefined
let btn: HTMLElement let btn: HTMLElement
const client = getClient()
async function updateSelected(value: Ref<Person>) {
selected = await client.findOne(contact.class.Person, { _id: value })
}
$: updateSelected(value)
onMount(() => { onMount(() => {
if (btn && show) { if (btn && show) {
btn.click() btn.click()
@ -50,7 +61,6 @@
on:click|preventDefault={(ev) => { on:click|preventDefault={(ev) => {
showPopup(UsersPopup, { _class, title, caption }, ev.target, (result) => { showPopup(UsersPopup, { _class, title, caption }, ev.target, (result) => {
if (result) { if (result) {
selected = result
value = result._id value = result._id
} }
}) })

View File

@ -32,6 +32,8 @@
export let candidate: Ref<Person> export let candidate: Ref<Person>
export let employee: Ref<Employee> export let employee: Ref<Employee>
export let preserveCandidate = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const client = getClient() const client = getClient()
@ -55,7 +57,9 @@
canSave={candidate !== undefined} canSave={candidate !== undefined}
on:close={() => { dispatch('close') }}> on:close={() => { dispatch('close') }}>
<Grid column={1} rowGap={1.75}> <Grid column={1} rowGap={1.75}>
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} /> {#if !preserveCandidate}
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} />
{/if}
<UserBox _class={contact.class.Employee} title='Assigned recruiter' caption='Recruiters' bind:value={employee} /> <UserBox _class={contact.class.Employee} title='Assigned recruiter' caption='Recruiters' bind:value={employee} />
</Grid> </Grid>
</Card> </Card>

View File

@ -27,7 +27,7 @@
</script> </script>
<div class="flex-center presenter-container" bind:this={button} <div class="flex-center presenter-container" bind:this={button}
on:click={() => { showPopup(CreateApplication, { candidate: object._id }, button) }} on:click={() => { showPopup(CreateApplication, { candidate: object._id, preserveCandidate: true }, button) }}
> >
<Label label="Create Application" /> <Label label="Create Application" />
</div> </div>