-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: budaeva <[email protected]>
- Loading branch information
Showing
18 changed files
with
404 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugins/contact-resources/src/components/EmployeePresenter.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script lang="ts"> | ||
import { Employee } from '@anticrm/contact' | ||
import EmployeeStatusPresenter from './EmployeeStatusPresenter.svelte' | ||
import PersonPresenter from '../components/PersonPresenter.svelte' | ||
import { showPopup } from '@anticrm/ui' | ||
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte' | ||
export let value: Employee | ||
export let shouldShowAvatar: boolean = true | ||
let container: HTMLElement | ||
function onEdit (event: MouseEvent) { | ||
showPopup( | ||
EmployeePreviewPopup, | ||
{ | ||
employeeId: value._id, | ||
space: value.space | ||
}, | ||
container | ||
) | ||
} | ||
</script> | ||
|
||
<div bind:this={container} class="flex container"> | ||
<div class="pr-2 over-underline"> | ||
<PersonPresenter {value} {onEdit} {shouldShowAvatar} /> | ||
</div> | ||
<div class="status"> | ||
<EmployeeStatusPresenter employeeId={value._id} /> | ||
</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.container { | ||
width: fit-content; | ||
margin-bottom: 0.25rem; | ||
} | ||
.status { | ||
font-weight: 400; | ||
font-size: 0.875rem; | ||
} | ||
</style> |
90 changes: 90 additions & 0 deletions
90
plugins/contact-resources/src/components/EmployeePreviewPopup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<script lang="ts"> | ||
import { Employee, formatName, Status } from '@anticrm/contact' | ||
import { Ref, Space, WithLookup } from '@anticrm/core' | ||
import { Avatar, createQuery, getClient } from '@anticrm/presentation' | ||
import { Button, Label, showPopup } from '@anticrm/ui' | ||
import EmployeeSetStatusPopup from './EmployeeSetStatusPopup.svelte' | ||
import contact from '../plugin' | ||
import EmployeeStatusPresenter from './EmployeeStatusPresenter.svelte' | ||
import Edit from './icons/Edit.svelte' | ||
import { createEventDispatcher } from 'svelte' | ||
export let employeeId: Ref<Employee> | ||
export let space: Ref<Space> | ||
const client = getClient() | ||
const stattusQuery = createQuery() | ||
let status: WithLookup<Status> | ||
$: employee = status?.$lookup?.attachedTo | ||
stattusQuery.query(contact.class.Status, { attachedTo: employeeId }, (res) => (status = res[0]), { | ||
lookup: { | ||
attachedTo: contact.class.Employee | ||
} | ||
}) | ||
const dispatch = createEventDispatcher() | ||
function onEdit () { | ||
showPopup( | ||
EmployeeSetStatusPopup, | ||
{ | ||
currentStatus: status | ||
}, | ||
undefined, | ||
() => {}, | ||
(newStatus: Status) => { | ||
if (status && newStatus) { | ||
client.update(status, { ...newStatus }) | ||
} else if (status && !newStatus) { | ||
client.remove(status) | ||
} else { | ||
client.createDoc(contact.class.Status, space, { | ||
attachedTo: employeeId, | ||
attachedToClass: contact.class.Employee, | ||
collection: 'statuses', | ||
name: newStatus.name, | ||
dueDate: newStatus.dueDate | ||
}) | ||
} | ||
} | ||
) | ||
dispatch('close') | ||
} | ||
</script> | ||
|
||
<div class="antiPopup p-4 flex-col"> | ||
<div class="flex-col-center pb-2"> | ||
<Avatar size="x-large" avatar={employee?.avatar} /> | ||
</div> | ||
<div class="pb-2">{formatName(employee?.name ?? '')}</div> | ||
<div class="pb-2"> | ||
<Label label={contact.string.Status} /> | ||
{#if status} | ||
<div class="flex-row-stretch statusContainer"> | ||
<div class="pr-2"> | ||
<EmployeeStatusPresenter {employeeId} withTooltip={false} /> | ||
</div> | ||
<div class="setStatusButton"> | ||
<Button icon={Edit} title={contact.string.SetStatus} on:click={onEdit} /> | ||
</div> | ||
</div> | ||
{:else} | ||
<div class="flex-row-stretch over-underline" on:click={onEdit}> | ||
<Label label={contact.string.SetStatus} /> | ||
</div> | ||
{/if} | ||
</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.statusContainer { | ||
.setStatusButton { | ||
opacity: 0; | ||
} | ||
&:hover .setStatusButton { | ||
opacity: 1; | ||
} | ||
} | ||
</style> |
51 changes: 51 additions & 0 deletions
51
plugins/contact-resources/src/components/EmployeeSetStatusPopup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
import { Status } from '@anticrm/contact' | ||
import { Timestamp } from '@anticrm/core' | ||
import { Card } from '@anticrm/presentation' | ||
import { EditBox, Grid, Label, ticker } from '@anticrm/ui' | ||
import { createEventDispatcher } from 'svelte' | ||
import contact from '../plugin' | ||
import EmployeeStatusDueDatePresenter from './EmployeeStatusDueDatePresenter.svelte' | ||
export let currentStatus: Status | undefined | ||
let statusName: string = currentStatus?.name ?? '' | ||
let statusDueDate: Timestamp | undefined = currentStatus?.dueDate | ||
const dispatch = createEventDispatcher() | ||
const handleDueDateChanged = async (event: CustomEvent<Timestamp>) => { | ||
statusDueDate = event.detail | ||
} | ||
$: statusChanged = statusName !== currentStatus?.name || statusDueDate !== currentStatus?.dueDate | ||
$: isOverdue = statusDueDate && statusDueDate < $ticker | ||
$: canSave = statusName.length > 0 && !isOverdue | ||
</script> | ||
|
||
<Card | ||
label={contact.string.SetStatus} | ||
okAction={() => { | ||
if (statusChanged) { | ||
dispatch('update', { | ||
name: statusName, | ||
dueDate: statusDueDate | ||
}) | ||
dispatch('close') | ||
} else { | ||
dispatch('update', undefined) | ||
dispatch('close') | ||
} | ||
}} | ||
{canSave} | ||
okLabel={statusChanged ? contact.string.SaveStatus : contact.string.ClearStatus} | ||
on:close={() => { | ||
dispatch('close') | ||
}} | ||
> | ||
<Grid column={1} rowGap={1}> | ||
<EditBox bind:value={statusName} maxWidth={'16rem'} /> | ||
<div><Label label={contact.string.StatusDueDate} /></div> | ||
|
||
<EmployeeStatusDueDatePresenter {statusDueDate} on:change={handleDueDateChanged} /> | ||
</Grid> | ||
</Card> |
23 changes: 23 additions & 0 deletions
23
plugins/contact-resources/src/components/EmployeeStatusDueDatePopup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import { Icon, IconDPCalendarOver, IconDPCalendar, Label } from '@anticrm/ui' | ||
import contact from '../plugin' | ||
export let isOverdue: boolean = false | ||
export let formattedDate: string | undefined | ||
</script> | ||
|
||
<div class="iconContainer"> | ||
<Icon icon={isOverdue ? IconDPCalendarOver : IconDPCalendar} size={'full'} /> | ||
{#if formattedDate} | ||
<div>{formattedDate}</div> | ||
{:else} | ||
<Label label={contact.string.NoExpire} /> | ||
{/if} | ||
</div> | ||
|
||
<style lang="scss"> | ||
.iconContainer { | ||
color: var(--content-color); | ||
margin-right: 1rem; | ||
} | ||
</style> |
34 changes: 34 additions & 0 deletions
34
plugins/contact-resources/src/components/EmployeeStatusDueDatePresenter.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import { Timestamp, TypeDate } from '@anticrm/core' | ||
import { ticker, Tooltip } from '@anticrm/ui' | ||
import { DateEditor } from '@anticrm/view-resources' | ||
import EmployeeStatusDueDatePopup from './EmployeeStatusDueDatePopup.svelte' | ||
import { formatDate } from '../utils' | ||
import { createEventDispatcher } from 'svelte' | ||
export let statusDueDate: Timestamp | undefined | ||
$: isOverdue = statusDueDate && statusDueDate < $ticker | ||
$: formattedDate = statusDueDate && formatDate(statusDueDate) | ||
const dispatch = createEventDispatcher() | ||
const type = { withTime: true } as TypeDate | ||
</script> | ||
|
||
<Tooltip | ||
direction={'top'} | ||
component={EmployeeStatusDueDatePopup} | ||
props={{ | ||
formattedDate, | ||
isOverdue | ||
}} | ||
> | ||
<DateEditor | ||
value={statusDueDate} | ||
{type} | ||
onChange={(v) => { | ||
statusDueDate = v | ||
dispatch('change', v) | ||
}} | ||
/> | ||
</Tooltip> |
Oops, something went wrong.