mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Employee status requests flood fix (#1759)
This commit is contained in:
parent
9cecb990ee
commit
0231234f9a
@ -60,7 +60,10 @@
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
))
|
||||
)),
|
||||
{
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
|
||||
$: updateQuery(space)
|
||||
|
@ -70,7 +70,10 @@
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
))
|
||||
)),
|
||||
{
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
|
||||
const pinnedQuery = createQuery()
|
||||
|
@ -124,7 +124,10 @@
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
))
|
||||
)),
|
||||
{
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
|
||||
const savedMessagesQuery = createQuery()
|
||||
|
@ -56,6 +56,7 @@
|
||||
"TypeLabel": "Type",
|
||||
"StatusDueDateTooltip": "Until {date}",
|
||||
"CopyToClipboard": "Copy to clipboard",
|
||||
"Copied": "Copied"
|
||||
"Copied": "Copied",
|
||||
"ViewFullProfile": "View full profile"
|
||||
}
|
||||
}
|
@ -56,6 +56,7 @@
|
||||
"TypeLabel": "Тип",
|
||||
"StatusDueDateTooltip": "До {date}",
|
||||
"CopyToClipboard": "Скопировать в буфер обмена",
|
||||
"Copied": "Скопировано"
|
||||
"Copied": "Скопировано",
|
||||
"ViewFullProfile": "Посмотреть профиль"
|
||||
}
|
||||
}
|
@ -4,8 +4,9 @@
|
||||
import PersonPresenter from '../components/PersonPresenter.svelte'
|
||||
import { showPopup } from '@anticrm/ui'
|
||||
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
|
||||
import { WithLookup } from '@anticrm/core'
|
||||
|
||||
export let value: Employee
|
||||
export let value: WithLookup<Employee>
|
||||
export let shouldShowAvatar: boolean = true
|
||||
|
||||
let container: HTMLElement
|
||||
@ -14,8 +15,7 @@
|
||||
showPopup(
|
||||
EmployeePreviewPopup,
|
||||
{
|
||||
employeeId: value._id,
|
||||
space: value.space
|
||||
employeeId: value._id
|
||||
},
|
||||
container
|
||||
)
|
||||
@ -26,9 +26,11 @@
|
||||
<div class="pr-2 over-underline">
|
||||
<PersonPresenter {value} {onEdit} {shouldShowAvatar} />
|
||||
</div>
|
||||
<div class="status content-color">
|
||||
<EmployeeStatusPresenter employeeId={value._id} />
|
||||
</div>
|
||||
{#if value.$lookup?.statuses?.length}
|
||||
<div class="status content-color">
|
||||
<EmployeeStatusPresenter employee={value} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -1,27 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { Employee, EmployeeAccount, formatName, Status } from '@anticrm/contact'
|
||||
import { getCurrentAccount, Ref, Space, WithLookup } from '@anticrm/core'
|
||||
import { getCurrentAccount, Ref, Hierarchy, WithLookup } from '@anticrm/core'
|
||||
import { Avatar, createQuery, getClient } from '@anticrm/presentation'
|
||||
import { Button, Label, showPopup } from '@anticrm/ui'
|
||||
import { Button, getPanelURI, 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'
|
||||
import view from '@anticrm/view'
|
||||
|
||||
export let employeeId: Ref<Employee>
|
||||
export let space: Ref<Space>
|
||||
|
||||
const client = getClient()
|
||||
const me = (getCurrentAccount() as EmployeeAccount).employee
|
||||
$: editable = employeeId === me
|
||||
|
||||
const stattusQuery = createQuery()
|
||||
let status: WithLookup<Status>
|
||||
$: employee = status?.$lookup?.attachedTo
|
||||
stattusQuery.query(contact.class.Status, { attachedTo: employeeId }, (res) => (status = res[0]), {
|
||||
const employeeQuery = createQuery()
|
||||
$: status = employee?.$lookup?.statuses?.[0]
|
||||
let employee: WithLookup<Employee> | undefined
|
||||
employeeQuery.query(contact.class.Employee, { _id: employeeId }, (res) => (employee = res[0]), {
|
||||
lookup: {
|
||||
attachedTo: contact.class.Employee
|
||||
_id: { statuses: contact.class.Status }
|
||||
}
|
||||
})
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
} else if (status && !newStatus) {
|
||||
client.removeDoc(contact.class.Status, status.space, status._id)
|
||||
} else {
|
||||
client.createDoc(contact.class.Status, space, {
|
||||
client.createDoc(contact.class.Status, employee!.space, {
|
||||
attachedTo: employeeId,
|
||||
attachedToClass: contact.class.Employee,
|
||||
collection: 'statuses',
|
||||
@ -56,28 +56,33 @@
|
||||
</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>
|
||||
{#if status}
|
||||
<div class="pb-2">
|
||||
<Label label={contact.string.Status} />
|
||||
<div class="flex-row-stretch statusContainer">
|
||||
<div class="pr-2">
|
||||
<EmployeeStatusPresenter {employeeId} withTooltip={false} />
|
||||
</div>
|
||||
{#if editable}
|
||||
<div class="setStatusButton">
|
||||
<Button icon={Edit} title={contact.string.SetStatus} on:click={onEdit} />
|
||||
{#if employee}
|
||||
<div class="flex-col-center pb-2">
|
||||
<Avatar size="x-large" avatar={employee?.avatar} />
|
||||
</div>
|
||||
<div class="pb-2">{formatName(employee?.name ?? '')}</div>
|
||||
<a href={`#${getPanelURI(view.component.EditDoc, employee._id, Hierarchy.mixinOrClass(employee), 'content')}`}
|
||||
><Label label={contact.string.ViewFullProfile} /></a
|
||||
>
|
||||
{#if status}
|
||||
<div class="pb-2">
|
||||
<Label label={contact.string.Status} />
|
||||
<div class="flex-row-stretch statusContainer">
|
||||
<div class="pr-2">
|
||||
<EmployeeStatusPresenter {employee} withTooltip={false} />
|
||||
</div>
|
||||
{/if}
|
||||
{#if editable}
|
||||
<div class="setStatusButton">
|
||||
<Button icon={Edit} title={contact.string.SetStatus} on:click={onEdit} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else if editable}
|
||||
<div class="flex-row-stretch over-underline pb-2" on:click={onEdit}>
|
||||
<Label label={contact.string.SetStatus} />
|
||||
</div>
|
||||
{:else if editable}
|
||||
<div class="flex-row-stretch over-underline pb-2" on:click={onEdit}>
|
||||
<Label label={contact.string.SetStatus} />
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
@ -1,38 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { Employee, Status } from '@anticrm/contact'
|
||||
import { Ref } from '@anticrm/core'
|
||||
import { WithLookup } from '@anticrm/core'
|
||||
import { Label, Tooltip } from '@anticrm/ui'
|
||||
import { createQuery } from '@anticrm/presentation'
|
||||
import contact from '../plugin'
|
||||
import { formatDate } from '../utils'
|
||||
import { IntlString } from '@anticrm/platform'
|
||||
|
||||
export let employeeId: Ref<Employee>
|
||||
export let employee: WithLookup<Employee>
|
||||
export let withTooltip: boolean = true
|
||||
|
||||
const statusQuery = createQuery()
|
||||
let status: Status
|
||||
|
||||
$: statusQuery.query(contact.class.Status, { attachedTo: employeeId }, (res) => {
|
||||
status = res[0]
|
||||
})
|
||||
|
||||
$: formattedDate = formatDate(status?.dueDate) as IntlString
|
||||
$: status = employee?.$lookup?.statuses?.[0] as Status | undefined
|
||||
$: formattedDate = status && (formatDate(status.dueDate) as IntlString)
|
||||
</script>
|
||||
|
||||
{#if status}
|
||||
{#if withTooltip}
|
||||
<Tooltip
|
||||
label={status?.dueDate ? contact.string.StatusDueDateTooltip : contact.string.NoExpire}
|
||||
label={status.dueDate ? contact.string.StatusDueDateTooltip : contact.string.NoExpire}
|
||||
props={{ date: formattedDate }}
|
||||
>
|
||||
<div class="overflow-label statusName">{status?.name}</div>
|
||||
<div class="overflow-label statusName">{status.name}</div>
|
||||
</Tooltip>
|
||||
{:else}
|
||||
<div class="flex">
|
||||
<div class="pr-4">{status?.name}</div>
|
||||
{#if status?.dueDate}
|
||||
<div>{formatDate(status?.dueDate)}</div>
|
||||
<div class="pr-4">{status.name}</div>
|
||||
{#if status.dueDate}
|
||||
<div>{formattedDate}</div>
|
||||
{:else}
|
||||
<Label label={contact.string.NoExpire} />
|
||||
{/if}
|
||||
|
@ -52,6 +52,7 @@ export default mergeIds(contactId, contact, {
|
||||
NoExpire: '' as IntlString,
|
||||
StatusDueDateTooltip: '' as IntlString,
|
||||
CopyToClipboard: '' as IntlString,
|
||||
Copied: '' as IntlString
|
||||
Copied: '' as IntlString,
|
||||
ViewFullProfile: '' as IntlString
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user