2022-05-12 07:05:26 +00:00
|
|
|
<script lang="ts">
|
2022-09-21 08:08:25 +00:00
|
|
|
import { Employee } from '@hcengineering/contact'
|
|
|
|
import { WithLookup } from '@hcengineering/core'
|
|
|
|
import { IntlString } from '@hcengineering/platform'
|
|
|
|
import type { AnyComponent, AnySvelteComponent } from '@hcengineering/ui'
|
|
|
|
import { showPopup } from '@hcengineering/ui'
|
2022-07-02 18:49:22 +00:00
|
|
|
import PersonPresenter from '../components/PersonPresenter.svelte'
|
|
|
|
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
|
|
|
|
import EmployeeStatusPresenter from './EmployeeStatusPresenter.svelte'
|
2022-05-12 07:05:26 +00:00
|
|
|
|
2022-06-07 08:57:05 +00:00
|
|
|
export let value: WithLookup<Employee> | null | undefined
|
2022-06-30 03:41:46 +00:00
|
|
|
export let tooltipLabels:
|
|
|
|
| {
|
|
|
|
personLabel?: IntlString
|
|
|
|
placeholderLabel?: IntlString
|
|
|
|
component?: AnySvelteComponent | AnyComponent
|
|
|
|
props?: any
|
|
|
|
}
|
|
|
|
| undefined = undefined
|
2022-05-12 07:05:26 +00:00
|
|
|
export let shouldShowAvatar: boolean = true
|
2022-05-18 05:35:34 +00:00
|
|
|
export let shouldShowName: boolean = true
|
2022-06-08 06:18:47 +00:00
|
|
|
export let shouldShowPlaceholder = false
|
2022-05-18 05:35:34 +00:00
|
|
|
export let onEmployeeEdit: ((event: MouseEvent) => void) | undefined = undefined
|
2022-06-10 16:10:15 +00:00
|
|
|
export let avatarSize: 'inline' | 'tiny' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large' = 'x-small'
|
2022-06-24 12:36:08 +00:00
|
|
|
export let isInteractive = true
|
|
|
|
export let inline = false
|
2022-09-09 03:44:33 +00:00
|
|
|
export let disableClick = false
|
2022-05-12 07:05:26 +00:00
|
|
|
|
|
|
|
let container: HTMLElement
|
|
|
|
|
2022-06-16 04:24:17 +00:00
|
|
|
const onEdit = (evt: MouseEvent) => {
|
2022-09-09 03:44:33 +00:00
|
|
|
if (disableClick) {
|
|
|
|
return
|
|
|
|
}
|
2022-06-16 04:24:17 +00:00
|
|
|
evt?.preventDefault()
|
|
|
|
evt?.stopPropagation()
|
2022-06-07 08:57:05 +00:00
|
|
|
if (value) {
|
|
|
|
showPopup(
|
|
|
|
EmployeePreviewPopup,
|
|
|
|
{
|
|
|
|
employeeId: value._id
|
|
|
|
},
|
|
|
|
container
|
|
|
|
)
|
|
|
|
}
|
2022-05-12 07:05:26 +00:00
|
|
|
}
|
2022-05-18 05:35:34 +00:00
|
|
|
|
|
|
|
$: handlePersonEdit = onEmployeeEdit ?? onEdit
|
2022-05-12 07:05:26 +00:00
|
|
|
</script>
|
|
|
|
|
2022-07-06 06:12:28 +00:00
|
|
|
<div bind:this={container} class:over-underline={!inline}>
|
|
|
|
<PersonPresenter
|
|
|
|
{value}
|
|
|
|
{tooltipLabels}
|
|
|
|
onEdit={isInteractive ? handlePersonEdit : () => {}}
|
|
|
|
{shouldShowAvatar}
|
|
|
|
{shouldShowName}
|
|
|
|
{avatarSize}
|
|
|
|
{shouldShowPlaceholder}
|
|
|
|
{isInteractive}
|
|
|
|
{inline}
|
|
|
|
/>
|
2022-05-12 07:05:26 +00:00
|
|
|
</div>
|
2022-07-06 06:12:28 +00:00
|
|
|
{#if value?.$lookup?.statuses?.length}
|
|
|
|
<div class="pl-2 status content-color">
|
|
|
|
<EmployeeStatusPresenter employee={value} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2022-05-12 07:05:26 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.status {
|
|
|
|
font-weight: 400;
|
|
|
|
font-size: 0.875rem;
|
|
|
|
}
|
|
|
|
</style>
|