Skip to content

Commit

Permalink
fix review issues (#1608)
Browse files Browse the repository at this point in the history
Signed-off-by: budaeva <irina.budaeva@xored.com>
  • Loading branch information
budaeva committed May 11, 2022
1 parent 2e384f8 commit a483e34
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 27 deletions.
8 changes: 5 additions & 3 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import contact from './plugin'

export const DOMAIN_CONTACT = 'contact' as Domain
export const DOMAIN_CHANNEL = 'channel' as Domain
export const DOMAIN_STATUS = 'status' as Domain

@Model(contact.class.ChannelProvider, core.class.Doc, DOMAIN_MODEL)
export class TChannelProvider extends TDoc implements ChannelProvider {
Expand Down Expand Up @@ -92,7 +91,7 @@ export class TPerson extends TContact implements Person {}
@UX(contact.string.Organization, contact.icon.Company, undefined, 'name')
export class TOrganization extends TContact implements Organization {}

@Model(contact.class.Status, core.class.AttachedDoc, DOMAIN_STATUS)
@Model(contact.class.Status, core.class.AttachedDoc, DOMAIN_CONTACT)
export class TStatus extends TAttachedDoc implements Status {
attachedTo!: Ref<Employee>;
attachedToClass!: Ref<Class<Employee>>;
Expand All @@ -102,7 +101,10 @@ export class TStatus extends TAttachedDoc implements Status {

@Model(contact.class.Employee, contact.class.Person)
@UX(contact.string.Employee, contact.icon.Person)
export class TEmployee extends TPerson implements Employee {}
export class TEmployee extends TPerson implements Employee {
@Prop(Collection(contact.class.Status), contact.string.Status)
statuses?: number
}

@Model(contact.class.EmployeeAccount, core.class.Account)
export class TEmployeeAccount extends TAccount implements EmployeeAccount {
Expand Down
3 changes: 2 additions & 1 deletion plugins/contact-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ClearStatus": "Clear status",
"SaveStatus": "Save",
"Cancel": "Cancel",
"StatusDueDate": "Due date"
"StatusDueDate": "Due date",
"NoExpire": "No expire"
}
}
3 changes: 2 additions & 1 deletion plugins/contact-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ClearStatus": "Очистить статус",
"SaveStatus": "Сохранить",
"Cancel": "Отмена",
"StatusDueDate": "Дата конца"
"StatusDueDate": "Дата конца",
"NoExpire": "Бессрочно"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<script lang="ts">
import { Icon, IconDPCalendarOver, IconDPCalendar } from '@anticrm/ui'
import { Icon, IconDPCalendarOver, IconDPCalendar, Label } from '@anticrm/ui'
import contact from '../plugin'
export let isOverdue: boolean = false
export let formattedDate: string = ''
export let formattedDate: string | undefined
</script>

<div class="iconContainer">
<Icon icon={isOverdue ? IconDPCalendarOver : IconDPCalendar} size={'full'} />
<div>{formattedDate}</div>
{#if formattedDate}
<div>{formattedDate}</div>
{:else}
<Label label={contact.string.NoExpire} />
{/if}
</div>

<style lang="scss">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<script lang="ts">
import { Timestamp } from '@anticrm/core'
import { DatePresenter, Tooltip } from '@anticrm/ui'
import { DatePresenter, ticker, 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)
$: isOverdue = statusDueDate && statusDueDate < $ticker
$: formattedDate = statusDueDate && formatDate(statusDueDate)
</script>

<Tooltip
direction={'top'}
component={EmployeeStatusDueDatePopup}
props={{
formattedDate: formattedDate,
formattedDate,
isOverdue
}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<script lang="ts">
import { Employee, Status } from '@anticrm/contact'
import { Ref } from '@anticrm/core'
import { Label } from '@anticrm/ui'
import { createQuery, getClient } from '@anticrm/presentation'
import contact from '../plugin'
import { formatDate } from '../utils'
export let employeeId: Ref<Employee>
export let withTooltip: boolean = true
Expand All @@ -27,14 +29,22 @@
{#if withTooltip}
<div class="tooltip-container">
<div class="tooltip">
{formatDate(status?.dueDate)}
{#if status?.dueDate}
<div>{formatDate(status?.dueDate)}</div>
{:else}
<Label label={contact.string.NoExpire} />
{/if}
</div>
<div>{status?.name}</div>
</div>
{:else}
<div class="flex">
<div class="pr-4">{status?.name}</div>
<div>{formatDate(status?.dueDate)}</div>
{#if status?.dueDate}
<div>{formatDate(status?.dueDate)}</div>
{:else}
<Label label={contact.string.NoExpire} />
{/if}
</div>
{/if}
{/if}
Expand Down
3 changes: 2 additions & 1 deletion plugins/contact-resources/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default mergeIds(contactId, contact, {
SaveStatus: '' as IntlString,
Cancel: '' as IntlString,
StatusDueDate: '' as IntlString,
StatusName: '' as IntlString
StatusName: '' as IntlString,
NoExpire: '' as IntlString
}
})
16 changes: 7 additions & 9 deletions plugins/contact-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ export async function getChannelProviders (): Promise<Map<Ref<ChannelProvider>,
return map
}

export function formatDate (dueDateMs: Timestamp | undefined): string {
return dueDateMs === undefined || dueDateMs === null
? 'no exp'
: new Date(dueDateMs).toLocaleString('default', {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
export function formatDate (dueDateMs: Timestamp): string {
return new Date(dueDateMs).toLocaleString('default', {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
}
4 changes: 3 additions & 1 deletion plugins/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export interface Status extends AttachedDoc {
/**
* @public
*/
export interface Employee extends Person {}
export interface Employee extends Person {
statuses?: number
}

/**
* @public
Expand Down

0 comments on commit a483e34

Please sign in to comment.