mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 09:51:53 +00:00
UBERF-10376: Allow todos filtering (#8729)
This commit is contained in:
parent
54df8dcf4b
commit
3bf36c524a
@ -298,7 +298,7 @@ class Connection implements ClientConnection {
|
||||
return
|
||||
}
|
||||
|
||||
if (resp.rateLimit !== undefined) {
|
||||
if (resp.rateLimit !== undefined && resp.rateLimit.remaining < 10) {
|
||||
console.log(
|
||||
'Rate limits:',
|
||||
resp.rateLimit.remaining,
|
||||
|
@ -10,7 +10,7 @@
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
|
||||
export let fullSize: boolean = false
|
||||
let value: string = ''
|
||||
export let value: string = ''
|
||||
let disabled: boolean = false
|
||||
|
||||
const client = getClient()
|
||||
@ -53,12 +53,12 @@
|
||||
clear()
|
||||
}
|
||||
|
||||
function clear () {
|
||||
function clear (): void {
|
||||
value = ''
|
||||
}
|
||||
|
||||
function openPopup () {
|
||||
showPopup(CreateToDoPopup, {}, 'top')
|
||||
function openPopup (): void {
|
||||
showPopup(CreateToDoPopup, { value }, 'top')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -32,13 +32,14 @@
|
||||
import Workslots from './Workslots.svelte'
|
||||
|
||||
export let object: Doc | undefined
|
||||
export let value: string = ''
|
||||
|
||||
const me = getCurrentEmployee()
|
||||
const myAccount = getCurrentAccount()
|
||||
|
||||
const todo: AttachedData<ToDo> = {
|
||||
workslots: 0,
|
||||
title: '',
|
||||
title: value,
|
||||
description: '',
|
||||
priority: ToDoPriority.NoPriority,
|
||||
attachedSpace: object?.space,
|
||||
|
@ -14,34 +14,34 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { DocumentQuery, Ref, WithLookup, IdMap } from '@hcengineering/core'
|
||||
import type { ToDo, WorkSlot } from '@hcengineering/time'
|
||||
import { getCurrentEmployee } from '@hcengineering/contact'
|
||||
import type { DocumentQuery, IdMap, Ref, WithLookup } from '@hcengineering/core'
|
||||
import { SortingOrder, toIdMap } from '@hcengineering/core'
|
||||
import type { IntlString } from '@hcengineering/platform'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import type { TagElement } from '@hcengineering/tags'
|
||||
import tags from '@hcengineering/tags'
|
||||
import type { ToDo, WorkSlot } from '@hcengineering/time'
|
||||
import type { Project } from '@hcengineering/tracker'
|
||||
import type { ToDosMode } from '..'
|
||||
import tracker from '@hcengineering/tracker'
|
||||
import {
|
||||
ButtonIcon,
|
||||
Header,
|
||||
IconMenuClose,
|
||||
IconMenuOpen,
|
||||
Label,
|
||||
Scroller,
|
||||
areDatesEqual,
|
||||
todosSP,
|
||||
defaultSP,
|
||||
Header,
|
||||
ButtonIcon,
|
||||
Label,
|
||||
IconMenuOpen,
|
||||
IconMenuClose,
|
||||
deviceOptionsStore as deviceInfo
|
||||
deviceOptionsStore as deviceInfo,
|
||||
todosSP
|
||||
} from '@hcengineering/ui'
|
||||
import { toIdMap, SortingOrder } from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import tracker from '@hcengineering/tracker'
|
||||
import tags from '@hcengineering/tags'
|
||||
import view from '@hcengineering/view-resources/src/plugin'
|
||||
import type { ToDosMode } from '..'
|
||||
import time from '../plugin'
|
||||
import { getNearest } from '../utils'
|
||||
import CreateToDo from './CreateToDo.svelte'
|
||||
import ToDoGroup from './ToDoGroup.svelte'
|
||||
import time from '../plugin'
|
||||
|
||||
export let mode: ToDosMode
|
||||
export let tag: Ref<TagElement> | undefined
|
||||
@ -197,9 +197,11 @@
|
||||
let inbox: WithLookup<ToDo>[] = []
|
||||
let done: WithLookup<ToDo>[] = []
|
||||
let rawActive: WithLookup<ToDo>[] = []
|
||||
let todoValue: string = ''
|
||||
|
||||
$: active = filterActive(mode, rawActive, currentDate)
|
||||
|
||||
$: groups = group(inbox, done, active)
|
||||
$: groups = group(inbox, done, active, todoValue)
|
||||
|
||||
function filterActive (mode: ToDosMode, raw: WithLookup<ToDo>[], currentDate: Date): WithLookup<ToDo>[] {
|
||||
if (mode === 'planned') {
|
||||
@ -233,13 +235,18 @@
|
||||
function group (
|
||||
unplanned: WithLookup<ToDo>[],
|
||||
done: WithLookup<ToDo>[],
|
||||
active: WithLookup<ToDo>[]
|
||||
active: WithLookup<ToDo>[],
|
||||
filterValue: string
|
||||
): [IntlString, WithLookup<ToDo>[]][] {
|
||||
const trimFilter = filterValue.trim().toLowerCase()
|
||||
|
||||
const filterOp = (it: WithLookup<ToDo>) => trimFilter === '' || it.title.toLowerCase().includes(trimFilter)
|
||||
|
||||
const groups = new Map<IntlString, WithLookup<ToDo>[]>([
|
||||
[time.string.Scheduled, []],
|
||||
[time.string.Unplanned, unplanned],
|
||||
[time.string.Unplanned, unplanned.filter(filterOp)],
|
||||
[time.string.ToDos, []],
|
||||
[time.string.Done, done]
|
||||
[time.string.Done, done.filter(filterOp)]
|
||||
])
|
||||
const now = Date.now()
|
||||
const todos: {
|
||||
@ -250,7 +257,7 @@
|
||||
nearest: WorkSlot | undefined
|
||||
todo: WithLookup<ToDo>
|
||||
}[] = []
|
||||
for (const todo of active) {
|
||||
for (const todo of active.filter(filterOp)) {
|
||||
if (todo.$lookup?.workslots !== undefined) {
|
||||
todo.$lookup.workslots = getWorkslots(todo).sort((a, b) => a.date - b.date)
|
||||
}
|
||||
@ -275,6 +282,13 @@
|
||||
time.string.Scheduled,
|
||||
scheduled.map((p) => p.todo)
|
||||
)
|
||||
if (trimFilter.length > 0) {
|
||||
for (const [k, v] of groups) {
|
||||
if (v.length === 0) {
|
||||
groups.delete(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
return Array.from(groups)
|
||||
}
|
||||
const getDateStr = (date: Date): string => {
|
||||
@ -313,8 +327,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
</Header>
|
||||
<CreateToDo fullSize />
|
||||
|
||||
<CreateToDo fullSize bind:value={todoValue} />
|
||||
<Scroller fade={filteredGroups.length > 1 ? todosSP : defaultSP} noStretch>
|
||||
{#each filteredGroups as group}
|
||||
<ToDoGroup
|
||||
|
Loading…
Reference in New Issue
Block a user