-
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.
Signed-off-by: budaeva <irina.budaeva@xored.com>
- Loading branch information
Showing
20 changed files
with
419 additions
and
18 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
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="container"> | ||
<div class="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="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-center 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="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> |
66 changes: 66 additions & 0 deletions
66
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,66 @@ | ||
<script lang="ts"> | ||
import { Status } from '@anticrm/contact' | ||
import { Timestamp } from '@anticrm/core' | ||
import { Button, EditBox, Label } 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 | ||
} | ||
</script> | ||
|
||
<div class="antiPopup antiPopup-withHeader popup"> | ||
<div class="ap-header"> | ||
<div class="ap-caption"> | ||
<Label label={contact.string.SetStatus} /> | ||
</div> | ||
</div> | ||
<div class="p-4 flex-col flex-gap-1"> | ||
<EditBox bind:value={statusName} maxWidth={'8rem'} /> | ||
<Label label={contact.string.StatusDueDate} /> | ||
|
||
<EmployeeStatusDueDatePresenter bind:statusDueDate on:change={handleDueDateChanged} /> | ||
</div> | ||
<div class="ap-footer"> | ||
{#if statusName.length > 0 && (statusName !== currentStatus?.name || statusDueDate !== currentStatus?.dueDate)} | ||
<Button | ||
on:click={() => { | ||
dispatch('close') | ||
}} | ||
label={contact.string.Cancel} | ||
/> | ||
<Button | ||
on:click={() => { | ||
dispatch('update', { | ||
name: statusName, | ||
dueDate: statusDueDate | ||
}) | ||
dispatch('close') | ||
}} | ||
label={contact.string.SaveStatus} | ||
/> | ||
{:else} | ||
<Button | ||
on:click={() => { | ||
dispatch('update', undefined) | ||
dispatch('close') | ||
}} | ||
label={contact.string.ClearStatus} | ||
/> | ||
{/if} | ||
</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.popup { | ||
width: 10rem; | ||
} | ||
</style> |
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
<script lang="ts"> | ||
import { Icon, IconDPCalendarOver, IconDPCalendar } from '@anticrm/ui' | ||
export let isOverdue: boolean = false | ||
export let formattedDate: string = '' | ||
</script> | ||
|
||
<div class="iconContainer"> | ||
<Icon icon={isOverdue ? IconDPCalendarOver : IconDPCalendar} size={'full'} /> | ||
<div>{formattedDate}</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.iconContainer { | ||
color: var(--content-color); | ||
margin-right: 1rem; | ||
} | ||
</style> |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
<script lang="ts"> | ||
import { Timestamp } from '@anticrm/core' | ||
import { DatePresenter, Tooltip } from '@anticrm/ui' | ||
import EmployeeStatusDueDatePopup from './EmployeeStatusDueDatePopup.svelte' | ||
import { formatDate } from '../utils' | ||
export let statusDueDate: Timestamp | undefined | ||
$: today = new Date(Date.now()) | ||
$: dueDateMs = statusDueDate | ||
$: isOverdue = dueDateMs !== undefined && dueDateMs !== null && dueDateMs < today.getTime() | ||
$: formattedDate = formatDate(dueDateMs) | ||
</script> | ||
|
||
<Tooltip | ||
direction={'top'} | ||
component={EmployeeStatusDueDatePopup} | ||
props={{ | ||
formattedDate: formattedDate, | ||
isOverdue | ||
}} | ||
> | ||
<DatePresenter bind:value={statusDueDate} editable={true} shouldShowLabel={true} withTime={true} on:change /> | ||
</Tooltip> |
Oops, something went wrong.