Show/hide completed applicants in all viewlets (#7428)

This commit is contained in:
Chunosov
2024-12-12 09:45:50 +07:00
committed by GitHub
parent 962f3816b9
commit fbb3471a49
5 changed files with 73 additions and 36 deletions
@@ -24,9 +24,11 @@
Ref,
SortingOrder,
TxOperations,
getObjectValue
getObjectValue,
mergeQueries
} from '@hcengineering/core'
import notification from '@hcengineering/notification'
import { getResource } from '@hcengineering/platform'
import { createQuery, getClient, reduceCalls, updateAttribute } from '@hcengineering/presentation'
import ui, {
Button,
@@ -39,7 +41,14 @@
mouseAttractor,
resizeObserver
} from '@hcengineering/ui'
import { AttributeModel, BuildModelKey, BuildModelOptions } from '@hcengineering/view'
import {
AttributeModel,
BuildModelKey,
BuildModelOptions,
ViewOptionModel,
ViewOptions,
ViewQueryOption
} from '@hcengineering/view'
import { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte'
import { showMenu } from '../actions'
@@ -59,6 +68,8 @@
export let tableId: string | undefined = undefined
export let readonly = false
export let showFooter = false
export let viewOptionsConfig: ViewOptionModel[] | undefined = undefined
export let viewOptions: ViewOptions | undefined = undefined
export let totalQuery: DocumentQuery<Doc> | undefined = undefined
@@ -117,6 +128,29 @@
: { ...(options?.sort ?? {}), [sortKey]: sortOrder }
}
async function getResultQuery (
query: DocumentQuery<Doc>,
viewOptions: ViewOptionModel[] | undefined,
viewOptionsStore: ViewOptions | undefined
): Promise<DocumentQuery<Doc>> {
if (viewOptions === undefined || viewOptionsStore === undefined) {
return query
}
let result: DocumentQuery<Doc> = hierarchy.clone(query)
for (const viewOption of viewOptions) {
if (viewOption.actionTarget !== 'query') continue
const queryOption = viewOption as ViewQueryOption
const f = await getResource(queryOption.action)
const resultP = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, result)
if (resultP instanceof Promise) {
result = await resultP
} else {
result = resultP
}
}
return result
}
const update = reduceCalls(async function (
_class: Ref<Class<Doc>>,
query: DocumentQuery<Doc>,
@@ -126,9 +160,11 @@
limit: number,
options?: FindOptions<Doc>
) {
const p = await getResultQuery(query, viewOptionsConfig, viewOptions)
const resultQuery = mergeQueries(p, query)
loading += q.query(
_class,
query,
resultQuery,
(result) => {
if (sortingFunction !== undefined) {
const sf = sortingFunction
@@ -16,7 +16,7 @@
import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@hcengineering/core'
import { ActionContext } from '@hcengineering/presentation'
import { FadeOptions, Scroller, tableSP } from '@hcengineering/ui'
import { BuildModelKey } from '@hcengineering/view'
import { BuildModelKey, ViewOptions, Viewlet } from '@hcengineering/view'
import { onMount } from 'svelte'
import { focusStore, ListSelectionProvider, SelectDirection } from '../selection'
import { LoadingProps } from '../utils'
@@ -34,6 +34,8 @@
export let tableId: string | undefined = undefined
export let fade: FadeOptions = tableSP
export let prefferedSorting: string = 'modifiedOn'
export let viewOptions: ViewOptions | undefined = undefined
export let viewlet: Viewlet | undefined = undefined
// If defined, will show a number of dummy items before real data will appear.
export let loadingProps: LoadingProps | undefined = undefined
@@ -79,6 +81,8 @@
checked={$selection ?? []}
{prefferedSorting}
{tableId}
{viewOptions}
viewOptionsConfig={viewlet?.viewOptions?.other}
selection={listProvider.current($focusStore)}
on:row-focus={(evt) => {
listProvider.updateFocus(evt.detail)