2023-01-14 10:54:54 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { Employee } from '@hcengineering/contact'
|
|
|
|
import { Ref } from '@hcengineering/core'
|
|
|
|
import { ButtonKind } from '@hcengineering/ui'
|
|
|
|
import { PersonLabelTooltip } from '..'
|
|
|
|
import contact from '../plugin'
|
2023-03-17 16:05:22 +00:00
|
|
|
import { employeeByIdStore } from '../utils'
|
2023-03-22 02:48:57 +00:00
|
|
|
import AssigneeBox from './AssigneeBox.svelte'
|
2023-01-14 10:54:54 +00:00
|
|
|
import EmployeePresenter from './EmployeePresenter.svelte'
|
|
|
|
|
|
|
|
export let value: Ref<Employee> | null | undefined
|
|
|
|
export let kind: ButtonKind = 'link'
|
|
|
|
export let tooltipLabels: PersonLabelTooltip | undefined = undefined
|
2023-02-07 04:52:34 +00:00
|
|
|
export let onChange: ((value: Ref<Employee>) => void) | undefined = undefined
|
2023-01-14 10:54:54 +00:00
|
|
|
|
2023-03-17 16:05:22 +00:00
|
|
|
$: employee = value ? $employeeByIdStore.get(value) : undefined
|
2023-01-14 10:54:54 +00:00
|
|
|
|
|
|
|
function getValue (
|
|
|
|
employee: Employee | undefined,
|
|
|
|
value: Ref<Employee> | null | undefined
|
|
|
|
): Employee | null | undefined {
|
|
|
|
if (value === undefined || value === null) {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
return employee
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-02-07 04:52:34 +00:00
|
|
|
{#if onChange !== undefined}
|
|
|
|
<AssigneeBox
|
|
|
|
label={contact.string.Employee}
|
|
|
|
{value}
|
|
|
|
size={'medium'}
|
|
|
|
kind={'link'}
|
|
|
|
showNavigate={false}
|
|
|
|
justify={'left'}
|
|
|
|
on:change={({ detail }) => onChange?.(detail)}
|
|
|
|
/>
|
|
|
|
{:else}
|
|
|
|
<EmployeePresenter
|
|
|
|
value={getValue(employee, value)}
|
|
|
|
{tooltipLabels}
|
|
|
|
isInteractive={false}
|
|
|
|
shouldShowAvatar
|
|
|
|
shouldShowPlaceholder
|
|
|
|
defaultName={contact.string.NotSpecified}
|
|
|
|
shouldShowName={kind !== 'list'}
|
|
|
|
avatarSize={kind === 'list-header' ? 'small' : 'x-small'}
|
|
|
|
disableClick
|
|
|
|
/>
|
|
|
|
{/if}
|