platform/plugins/contact-resources/src/components/EmployeeAttributePresenter.svelte
Andrey Sobolev ef987eef56
TSK-1323: Fix colors for list (#3069)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
2023-04-25 23:11:50 +07:00

60 lines
1.7 KiB
Svelte

<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'
import { employeeByIdStore } from '../utils'
import AssigneeBox from './AssigneeBox.svelte'
import EmployeePresenter from './EmployeePresenter.svelte'
export let value: Ref<Employee> | null | undefined
export let kind: ButtonKind = 'link'
export let tooltipLabels: PersonLabelTooltip | undefined = undefined
export let onChange: ((value: Ref<Employee>) => void) | undefined = undefined
export let colorInherit: boolean = false
export let accent: boolean = false
export let inline = false
$: employee = value ? $employeeByIdStore.get(value) : undefined
function getValue (
employee: Employee | undefined,
value: Ref<Employee> | null | undefined
): Employee | null | undefined {
if (value === undefined || value === null) {
return value
}
return employee
}
</script>
{#if onChange !== undefined}
<AssigneeBox
label={contact.string.Employee}
{value}
size={'medium'}
kind={'link'}
showNavigate={false}
justify={'left'}
on:change={({ detail }) => onChange?.(detail)}
on:accent-color
/>
{:else}
<EmployeePresenter
value={getValue(employee, value)}
{inline}
{tooltipLabels}
isInteractive={false}
shouldShowAvatar
shouldShowPlaceholder
defaultName={contact.string.NotSpecified}
shouldShowName={kind !== 'list'}
avatarSize={kind === 'list-header' ? 'smaller' : 'x-small'}
disableClick
{colorInherit}
{accent}
on:accent-color
/>
{/if}