Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker: Rewrite AssigneePresenter #1568

Merged
merged 7 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 219 additions & 219 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/kanban/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/ui": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"lexorank": "^1.0.4",
"@anticrm/platform": "~0.6.5",
"@anticrm/core": "~0.6.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@anticrm/ui": "~0.6.0",
"@anticrm/text-editor": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/platform": "~0.6.5",
"@anticrm/core": "~0.6.16",
"@anticrm/chunter": "~0.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@anticrm/query": "~0.6.1",
"@anticrm/ui": "~0.6.0",
"@anticrm/view": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/contact": "~0.6.5",
"@anticrm/login": "~0.6.1",
"@anticrm/image-cropper": "~0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/text-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/prosemirror-model": "~1.16.0"
},
"dependencies": {
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/presentation": "~0.6.2",
"@anticrm/contact": "~0.6.5",
"@anticrm/platform": "~0.6.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"typescript": "^4.3.5"
},
"dependencies": {
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/platform": "~0.6.5"
}
}
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"dependencies": {
"@anticrm/platform": "~0.6.5",
"@anticrm/theme": "~0.6.0",
"svelte": "^3.46"
"svelte": "^3.47"
}
}
2 changes: 1 addition & 1 deletion plugins/activity-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
"@anticrm/activity": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/chunter": "~0.6.1",
"@anticrm/text-editor": "~0.6.0",
"@anticrm/contact": "~0.6.5",
Expand Down
2 changes: 1 addition & 1 deletion plugins/attachment-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
"@anticrm/attachment": "~0.6.1",
Expand Down
2 changes: 1 addition & 1 deletion plugins/board-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@anticrm/view": "~0.6.0",
"@anticrm/view-resources": "~0.6.0",
"@anticrm/workbench": "~0.6.1",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/kanban": "~0.6.0"
}
}
2 changes: 1 addition & 1 deletion plugins/calendar-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
"@anticrm/calendar": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/text-editor": "~0.6.0",
"@anticrm/contact": "~0.6.2",
"@anticrm/contact-resources": "~0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/chunter-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@anticrm/presentation": "~0.6.2",
"@anticrm/chunter": "~0.6.1",
"@anticrm/login": "~0.6.1",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/text-editor": "~0.6.0",
"@anticrm/contact": "~0.6.5",
"@anticrm/contact-resources": "~0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/contact-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/contact": "~0.6.5",
"@anticrm/ui": "~0.6.0",
"@anticrm/setting": "~0.6.0",
Expand Down
119 changes: 99 additions & 20 deletions plugins/contact-resources/src/components/PersonContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,114 @@
<script lang="ts">
import { formatName, Person } from '@anticrm/contact'
import { Hierarchy } from '@anticrm/core'
import { IntlString } from '@anticrm/platform'
import { Avatar } from '@anticrm/presentation'
import { getPanelURI } from '@anticrm/ui'
import { getPanelURI, Label } from '@anticrm/ui'
import view from '@anticrm/view'

export let value: Person | undefined
export let inline: boolean = false
export let isInteractive = true
export let shouldShowName = true
export let shouldShowPlaceholder = false
export let defaultName: IntlString | undefined = undefined
export let avatarSize: 'inline' | 'tiny' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large' = 'x-small'
export let onEdit: ((event: MouseEvent) => void) | undefined = undefined

const avatarSize = 'x-small'
$: element = getElement(value, onEdit, shouldShowPlaceholder, isInteractive)

const getElement = (
person: Person | undefined,
onEdit: Function | undefined,
shouldShowEmpty: boolean,
isInteractive: boolean
) => {
if (!person && !shouldShowEmpty) {
return undefined
}

if (!isInteractive) {
return 'div'
}

if (person && !onEdit) {
return 'a'
}

return 'div'
}
</script>

{#if value || shouldShowPlaceholder}
{#if value}
<a
class="flex-presenter"
class:inline-presenter={inline}
href="#{getPanelURI(view.component.EditDoc, value._id, Hierarchy.mixinOrClass(value), 'content')}"
>
<div class="icon">
<Avatar size={avatarSize} avatar={value?.avatar} />
</div>
{#if shouldShowName}
<span class="label">{formatName(value.name)}</span>
{/if}
</a>
{:else}
<div class="icon">
<Avatar size={avatarSize} avatar={undefined} />
<svelte:element
this={element}
class="contentPresenter"
class:inline-presenter={inline}
class:mContentPresenterNotInteractive={!isInteractive}
on:click={onEdit}
href={!isInteractive || onEdit || !value
? undefined
: `#${getPanelURI(view.component.EditDoc, value._id, Hierarchy.mixinOrClass(value), 'content')}`}
>
<div class="eContentPresenterIcon">
<Avatar size={avatarSize} avatar={value?.avatar} />
</div>
{#if value && shouldShowName}
<span class="eContentPresenterLabel">{formatName(value.name)}</span>
{/if}
{#if !value && shouldShowName && defaultName}
<div class="eContentPresenterLabel">
<Label label={defaultName} />
</div>
{/if}
{/if}
</svelte:element>

<style lang="scss">
.contentPresenter {
display: flex;
align-items: center;
flex-wrap: nowrap;
cursor: pointer;

&.mContentPresenterNotInteractive {
cursor: default;

&:hover {
.eContentPresenterIcon {
color: var(--theme-content-dark-color);
}
.eContentPresenterLabel {
text-decoration: none;
color: var(--theme-content-accent-color);
}
}
}
.eContentPresenterIcon {
margin-right: 0.5rem;
color: var(--theme-content-dark-color);
}
.eContentPresenterLabel {
min-width: 0;
font-weight: 500;
text-align: left;
color: var(--theme-content-accent-color);

overflow: hidden;
visibility: visible;
display: -webkit-box;
/* autoprefixer: ignore next */
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
user-select: none;
}
&:hover {
.eContentPresenterIcon {
color: var(--theme-caption-color);
}
.eContentPresenterLabel {
text-decoration: underline;
color: var(--theme-caption-color);
}
}
}
</style>
31 changes: 26 additions & 5 deletions plugins/contact-resources/src/components/PersonPresenter.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
// 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
Expand All @@ -20,10 +19,14 @@
import PersonContent from './PersonContent.svelte'

export let value: Person
export let inline: boolean = false
export let inline = false
export let isInteractive = true
export let shouldShowName = true
export let shouldShowPlaceholder = false
export let defaultName: IntlString | undefined = undefined
export let tooltipLabels: { personLabel: IntlString; placeholderLabel?: IntlString } | undefined = undefined
export let avatarSize: 'inline' | 'tiny' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large' = 'x-small'
export let onEdit: ((event: MouseEvent) => void) | undefined = undefined
</script>

{#if value || shouldShowPlaceholder}
Expand All @@ -32,9 +35,27 @@
label={value ? tooltipLabels.personLabel : tooltipLabels.placeholderLabel}
props={{ value: formatName(value?.name) }}
>
<PersonContent {inline} {value} {shouldShowName} {shouldShowPlaceholder} />
<PersonContent
{value}
{inline}
{onEdit}
{avatarSize}
{defaultName}
{isInteractive}
{shouldShowName}
{shouldShowPlaceholder}
/>
</Tooltip>
{:else}
<PersonContent {inline} {value} {shouldShowName} {shouldShowPlaceholder} />
<PersonContent
{value}
{inline}
{onEdit}
{avatarSize}
{defaultName}
{isInteractive}
{shouldShowName}
{shouldShowPlaceholder}
/>
{/if}
{/if}
2 changes: 1 addition & 1 deletion plugins/devmodel-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
"@anticrm/activity": "~0.6.0",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/chunter": "~0.6.1",
"@anticrm/text-editor": "~0.6.0",
"@anticrm/contact": "~0.6.5",
Expand Down
2 changes: 1 addition & 1 deletion plugins/gmail-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/gmail": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/image-cropper-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"typescript": "^4.3.5"
},
"dependencies": {
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/platform": "~0.6.5",
"cropperjs": "~1.5.12",
"smartcrop": "~2.0.5"
Expand Down
2 changes: 1 addition & 1 deletion plugins/inventory-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/inventory": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/panel": "~0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/lead-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/lead": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/login-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/login": "~0.6.1",
"@anticrm/ui": "~0.6.0",
"@anticrm/workbench": "~0.6.1"
Expand Down
2 changes: 1 addition & 1 deletion plugins/notification-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/notification": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/recruit-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@anticrm/platform": "~0.6.5",
"@anticrm/core": "~0.6.16",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/recruit": "~0.6.3",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/setting-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@anticrm/platform": "~0.6.5",
"@anticrm/core": "~0.6.16",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/setting": "~0.6.0",
"@anticrm/contact": "~0.6.5",
"@anticrm/attachment": "~0.6.1",
Expand Down
2 changes: 1 addition & 1 deletion plugins/tags-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/tags": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/task-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@anticrm/platform": "~0.6.5",
"svelte": "^3.46",
"svelte": "^3.47",
"@anticrm/task": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2",
Expand Down
Loading