mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-15 04:49:00 +00:00
Add checklist dueTo (#1796)
Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
parent
298a277729
commit
8abadca450
@ -17,12 +17,22 @@
|
|||||||
import { createQuery, getClient, UserBox, MessageBox } from '@anticrm/presentation'
|
import { createQuery, getClient, UserBox, MessageBox } from '@anticrm/presentation'
|
||||||
import type { TodoItem } from '@anticrm/task'
|
import type { TodoItem } from '@anticrm/task'
|
||||||
import task from '@anticrm/task'
|
import task from '@anticrm/task'
|
||||||
import { Button, CheckBox, TextAreaEditor, Icon, IconMoreH, Progress, showPopup } from '@anticrm/ui'
|
import {
|
||||||
|
Button,
|
||||||
|
CheckBox,
|
||||||
|
TextAreaEditor,
|
||||||
|
Icon,
|
||||||
|
IconMoreH,
|
||||||
|
Progress,
|
||||||
|
showPopup,
|
||||||
|
DateRangePresenter
|
||||||
|
} from '@anticrm/ui'
|
||||||
import { ContextMenu, HTMLPresenter } from '@anticrm/view-resources'
|
import { ContextMenu, HTMLPresenter } from '@anticrm/view-resources'
|
||||||
import contact, { Employee } from '@anticrm/contact'
|
import contact, { Employee } from '@anticrm/contact'
|
||||||
|
|
||||||
import board from '../../plugin'
|
import board from '../../plugin'
|
||||||
import { getPopupAlignment } from '../../utils/PopupUtils'
|
import { getPopupAlignment } from '../../utils/PopupUtils'
|
||||||
|
import { getDateIcon } from '../../utils/BoardUtils'
|
||||||
|
|
||||||
export let value: TodoItem
|
export let value: TodoItem
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
@ -94,6 +104,10 @@
|
|||||||
client.update(item, { assignee })
|
client.update(item, { assignee })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateDueDate (item: TodoItem, dueTo: number) {
|
||||||
|
client.update(item, { dueTo })
|
||||||
|
}
|
||||||
|
|
||||||
async function setDoneToChecklistItem (item: TodoItem, event: CustomEvent<boolean>) {
|
async function setDoneToChecklistItem (item: TodoItem, event: CustomEvent<boolean>) {
|
||||||
const isDone = event.detail
|
const isDone = event.detail
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@ -206,7 +220,13 @@
|
|||||||
>
|
>
|
||||||
<HTMLPresenter bind:value={item.name} />
|
<HTMLPresenter bind:value={item.name} />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-center">
|
<div class="flex-center gap-1">
|
||||||
|
<DateRangePresenter
|
||||||
|
editable
|
||||||
|
bind:value={item.dueTo}
|
||||||
|
icon={getDateIcon(item)}
|
||||||
|
on:change={(e) => updateDueDate(item, e.detail)}
|
||||||
|
/>
|
||||||
<UserBox
|
<UserBox
|
||||||
_class={contact.class.Employee}
|
_class={contact.class.Employee}
|
||||||
label={board.string.Assignee}
|
label={board.string.Assignee}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Icon } from '@anticrm/ui'
|
import { DatePresenter, Icon } from '@anticrm/ui'
|
||||||
import board, { Card } from '@anticrm/board'
|
import board, { Card } from '@anticrm/board'
|
||||||
import { createQuery } from '@anticrm/presentation'
|
import { createQuery } from '@anticrm/presentation'
|
||||||
import task, { TodoItem } from '@anticrm/task'
|
import task, { TodoItem } from '@anticrm/task'
|
||||||
import { Ref } from '@anticrm/core'
|
import { Ref } from '@anticrm/core'
|
||||||
|
import { getDateIcon } from '../../utils/BoardUtils'
|
||||||
|
|
||||||
export let value: Card
|
export let value: Card
|
||||||
export let size: 'small' | 'medium' | 'large' = 'small'
|
export let size: 'small' | 'medium' | 'large' = 'small'
|
||||||
@ -14,10 +15,13 @@
|
|||||||
todoLists = result.map(({ _id }) => _id)
|
todoLists = result.map(({ _id }) => _id)
|
||||||
})
|
})
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
let done: number, total: number
|
let done: number, total: number, item: TodoItem
|
||||||
$: query.query(task.class.TodoItem, { space: value.space, attachedTo: { $in: todoLists } }, (result) => {
|
$: query.query(task.class.TodoItem, { space: value.space, attachedTo: { $in: todoLists } }, (result) => {
|
||||||
total = result.total
|
total = result.total
|
||||||
done = result.filter((t) => t.done).length
|
done = result.filter((t) => t.done).length
|
||||||
|
item = result.reduce((min, cur) =>
|
||||||
|
cur.dueTo === null ? min : min.dueTo === null || cur.dueTo < min.dueTo ? cur : min
|
||||||
|
)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -25,5 +29,8 @@
|
|||||||
<div class="sm-tool-icon ml-1 mr-1">
|
<div class="sm-tool-icon ml-1 mr-1">
|
||||||
<Icon icon={board.icon.Card} {size} />
|
<Icon icon={board.icon.Card} {size} />
|
||||||
{done}/{total}
|
{done}/{total}
|
||||||
|
{#if item.dueTo !== null}
|
||||||
|
<DatePresenter value={item.dueTo} size="small" icon={getDateIcon(item)} kind="transparent" />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import board, { Board, CardLabel, Card } from '@anticrm/board'
|
import board, { Board, CardLabel, Card } from '@anticrm/board'
|
||||||
import core, { Ref, TxOperations, Space } from '@anticrm/core'
|
import core, { Ref, TxOperations, Space } from '@anticrm/core'
|
||||||
import type { KanbanTemplate } from '@anticrm/task'
|
import type { KanbanTemplate, TodoItem } from '@anticrm/task'
|
||||||
import { createKanban } from '@anticrm/task'
|
import { createKanban } from '@anticrm/task'
|
||||||
import {
|
import {
|
||||||
hexColorToNumber,
|
hexColorToNumber,
|
||||||
@ -13,7 +13,8 @@ import {
|
|||||||
FeijoaColor,
|
FeijoaColor,
|
||||||
EastSideColor,
|
EastSideColor,
|
||||||
SalmonColor,
|
SalmonColor,
|
||||||
SeagullColor
|
SeagullColor,
|
||||||
|
areDatesEqual
|
||||||
} from '@anticrm/ui'
|
} from '@anticrm/ui'
|
||||||
|
|
||||||
export async function createBoard (
|
export async function createBoard (
|
||||||
@ -119,3 +120,10 @@ export async function createMissingLabels (
|
|||||||
|
|
||||||
return labelsUpdate
|
return labelsUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDateIcon (item: TodoItem): 'normal' | 'warning' | 'overdue' {
|
||||||
|
if (item.dueTo === null) return 'normal'
|
||||||
|
const date = new Date()
|
||||||
|
const dueDate = new Date(item.dueTo)
|
||||||
|
return areDatesEqual(date, dueDate) ? 'warning' : dueDate < date ? 'overdue' : 'normal'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user