2022-04-08 18:05:49 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2023-03-09 09:05:42 +00:00
|
|
|
import { Employee, getName, Person } from '@hcengineering/contact'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { IntlString } from '@hcengineering/platform'
|
2023-03-15 14:06:03 +00:00
|
|
|
import { Label, LabelAndProps, tooltip } from '@hcengineering/ui'
|
2023-04-23 17:37:24 +00:00
|
|
|
import type { IconSize } from '@hcengineering/ui'
|
2023-03-15 14:06:03 +00:00
|
|
|
import { DocNavLink } from '@hcengineering/view-resources'
|
2023-03-22 02:48:57 +00:00
|
|
|
import Avatar from './Avatar.svelte'
|
2022-04-08 18:05:49 +00:00
|
|
|
|
2023-03-09 09:05:42 +00:00
|
|
|
export let value: Person | Employee | undefined | null
|
2022-04-08 18:05:49 +00:00
|
|
|
export let inline: boolean = false
|
2022-04-28 12:03:10 +00:00
|
|
|
export let isInteractive = true
|
2022-05-12 07:05:26 +00:00
|
|
|
export let shouldShowAvatar: boolean = true
|
2022-04-08 18:05:49 +00:00
|
|
|
export let shouldShowName = true
|
|
|
|
export let shouldShowPlaceholder = false
|
2022-04-28 12:03:10 +00:00
|
|
|
export let defaultName: IntlString | undefined = undefined
|
2023-03-17 03:52:32 +00:00
|
|
|
export let statusLabel: IntlString | undefined = undefined
|
2023-04-23 17:37:24 +00:00
|
|
|
export let avatarSize: IconSize = 'x-small'
|
2022-04-28 12:03:10 +00:00
|
|
|
export let onEdit: ((event: MouseEvent) => void) | undefined = undefined
|
2022-06-07 04:10:34 +00:00
|
|
|
export let showTooltip: LabelAndProps | undefined = undefined
|
2022-08-25 03:11:10 +00:00
|
|
|
export let enlargedText = false
|
2023-03-14 05:08:23 +00:00
|
|
|
export let element: HTMLElement | undefined = undefined
|
2023-04-23 17:37:24 +00:00
|
|
|
export let colorInherit: boolean = false
|
|
|
|
export let accent: boolean = false
|
2023-03-20 09:15:53 +00:00
|
|
|
|
|
|
|
const onEditClick = (evt: MouseEvent) => {
|
|
|
|
if (isInteractive) {
|
|
|
|
onEdit?.(evt)
|
|
|
|
}
|
|
|
|
}
|
2022-04-08 18:05:49 +00:00
|
|
|
</script>
|
|
|
|
|
2023-03-15 14:06:03 +00:00
|
|
|
{#if value}
|
2023-04-23 17:37:24 +00:00
|
|
|
<DocNavLink object={value} onClick={onEdit} disableClick={!isInteractive} {inline} {colorInherit}>
|
2023-03-17 03:52:32 +00:00
|
|
|
<span
|
|
|
|
use:tooltip={showTooltip}
|
|
|
|
class="contentPresenter"
|
|
|
|
class:text-base={enlargedText}
|
|
|
|
class:inline-presenter={inline}
|
|
|
|
>
|
2023-03-27 06:16:20 +00:00
|
|
|
{#if !inline && shouldShowAvatar}
|
2023-03-15 14:06:03 +00:00
|
|
|
<span
|
|
|
|
class="eContentPresenterIcon"
|
|
|
|
class:mr-2={shouldShowName && !enlargedText}
|
|
|
|
class:mr-3={shouldShowName && enlargedText}
|
|
|
|
>
|
2023-04-25 16:11:50 +00:00
|
|
|
<Avatar size={avatarSize} avatar={value.avatar} on:accent-color />
|
2023-03-15 14:06:03 +00:00
|
|
|
</span>
|
|
|
|
{/if}
|
|
|
|
{#if shouldShowName}
|
2023-04-23 17:37:24 +00:00
|
|
|
<span class="eContentPresenterLabel" class:colorInherit>{getName(value)}</span>
|
2023-03-15 14:06:03 +00:00
|
|
|
{/if}
|
|
|
|
</span>
|
|
|
|
</DocNavLink>
|
2023-03-17 03:52:32 +00:00
|
|
|
{#if statusLabel}
|
|
|
|
<span class="status">
|
|
|
|
<Label label={statusLabel} />
|
|
|
|
</span>
|
|
|
|
{/if}
|
2023-03-15 14:06:03 +00:00
|
|
|
{:else if shouldShowPlaceholder}
|
2023-03-20 09:15:53 +00:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
|
<span use:tooltip={showTooltip} on:click={onEditClick} class="contentPresenter" class:text-base={enlargedText}>
|
2023-03-27 06:16:20 +00:00
|
|
|
{#if !inline && shouldShowAvatar}
|
2023-03-15 14:06:03 +00:00
|
|
|
<span
|
|
|
|
class="eContentPresenterIcon"
|
|
|
|
class:mr-2={shouldShowName && !enlargedText}
|
|
|
|
class:mr-3={shouldShowName && enlargedText}
|
|
|
|
>
|
2023-04-25 16:11:50 +00:00
|
|
|
<Avatar size={avatarSize} on:accent-color />
|
2023-03-15 14:06:03 +00:00
|
|
|
</span>
|
|
|
|
{/if}
|
|
|
|
{#if shouldShowName && defaultName}
|
2023-04-23 17:37:24 +00:00
|
|
|
<span class="eContentPresenterLabel" class:colorInherit>
|
2023-03-15 14:06:03 +00:00
|
|
|
<Label label={defaultName} />
|
|
|
|
</span>
|
2023-03-17 03:52:32 +00:00
|
|
|
{#if statusLabel}
|
|
|
|
<span class="eContentStatusLabel">
|
|
|
|
<Label label={statusLabel} />
|
|
|
|
</span>
|
|
|
|
{/if}
|
2023-03-15 14:06:03 +00:00
|
|
|
{/if}
|
|
|
|
</span>
|
|
|
|
{/if}
|
2022-04-28 12:03:10 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.contentPresenter {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-wrap: nowrap;
|
|
|
|
|
2023-03-14 05:08:23 +00:00
|
|
|
&.inline-presenter {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: baseline;
|
|
|
|
}
|
2022-04-28 12:03:10 +00:00
|
|
|
.eContentPresenterIcon {
|
2022-07-06 06:12:28 +00:00
|
|
|
color: var(--dark-color);
|
2022-04-28 12:03:10 +00:00
|
|
|
}
|
|
|
|
.eContentPresenterLabel {
|
|
|
|
min-width: 0;
|
|
|
|
font-weight: 500;
|
|
|
|
text-align: left;
|
2023-04-23 17:37:24 +00:00
|
|
|
color: var(--theme-caption-color);
|
2022-04-28 12:03:10 +00:00
|
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
visibility: visible;
|
|
|
|
display: -webkit-box;
|
|
|
|
/* autoprefixer: ignore next */
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
line-clamp: 2;
|
|
|
|
user-select: none;
|
2023-04-23 17:37:24 +00:00
|
|
|
|
|
|
|
&.colorInherit {
|
|
|
|
color: inherit;
|
|
|
|
}
|
2022-04-28 12:03:10 +00:00
|
|
|
}
|
|
|
|
&:hover {
|
|
|
|
.eContentPresenterIcon {
|
2023-04-23 17:37:24 +00:00
|
|
|
color: var(--theme-caption-color);
|
2022-04-28 12:03:10 +00:00
|
|
|
}
|
|
|
|
.eContentPresenterLabel {
|
|
|
|
text-decoration: underline;
|
2023-04-23 17:37:24 +00:00
|
|
|
color: var(--theme-caption-color);
|
2022-04-28 12:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-17 03:52:32 +00:00
|
|
|
.status {
|
|
|
|
margin-left: 0.25rem;
|
|
|
|
padding: 0.125rem 0.25rem;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 0.75rem;
|
|
|
|
color: var(--content-color);
|
|
|
|
background-color: var(--noborder-bg-color);
|
|
|
|
border-radius: 0.25rem;
|
|
|
|
}
|
2022-04-28 12:03:10 +00:00
|
|
|
</style>
|