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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 73 additions and 36 deletions

View File

@ -435,6 +435,26 @@ export function createModel (builder: Builder): void {
}, },
recruit.viewlet.TableApplicant recruit.viewlet.TableApplicant
) )
const applicationDoneOption: ViewOptionModel = {
key: 'hideDoneState',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideDoneState,
label: recruit.string.HideDoneState
}
// hiding applicants related to archived vacancies from applicants view
const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = {
key: 'hideArchivedVacancies',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideArchivedVacancies,
label: recruit.string.HideApplicantsFromArchivedVacancies
}
builder.createDoc( builder.createDoc(
view.class.Viewlet, view.class.Viewlet,
core.space.Model, core.space.Model,
@ -479,9 +499,10 @@ export function createModel (builder: Builder): void {
hiddenKeys: ['name', 'attachedTo'], hiddenKeys: ['name', 'attachedTo'],
sortable: true sortable: true
}, },
baseQuery: { viewOptions: {
isDone: false, groupBy: [],
'$lookup.space.archived': false orderBy: [],
other: [applicationDoneOption, hideApplicantsFromArchivedVacanciesOption]
} }
}, },
recruit.viewlet.ApplicantTable recruit.viewlet.ApplicantTable
@ -519,25 +540,6 @@ export function createModel (builder: Builder): void {
] ]
} }
const applicationDoneOption: ViewOptionModel = {
key: 'hideDoneState',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideDoneState,
label: recruit.string.HideDoneState
}
// hiding applicants related to archived vacancies from applicants view
const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = {
key: 'hideArchivedVacancies',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideArchivedVacancies,
label: recruit.string.HideApplicantsFromArchivedVacancies
}
const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => { const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => {
const model: ViewOptionsModel = { const model: ViewOptionsModel = {
groupBy: ['status', 'assignee', 'space', 'createdBy', 'modifiedBy'], groupBy: ['status', 'assignee', 'space', 'createdBy', 'modifiedBy'],
@ -794,13 +796,8 @@ export function createModel (builder: Builder): void {
{ {
attachTo: recruit.class.Applicant, attachTo: recruit.class.Applicant,
descriptor: task.viewlet.Kanban, descriptor: task.viewlet.Kanban,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
baseQuery: {
isDone: false,
'$lookup.space.archived': false
},
viewOptions: { viewOptions: {
...applicantViewOptions(false, false), ...applicantViewOptions(false, true),
groupDepth: 1 groupDepth: 1
}, },
options: { options: {

View File

@ -17,7 +17,7 @@ import {
type ViewQueryOption, type ViewQueryOption,
type Viewlet type Viewlet
} from '@hcengineering/view' } from '@hcengineering/view'
import { getCategories, getCategorySpaces } from '@hcengineering/view-resources' import { getCategories, getCategorySpaces, concatCategories } from '@hcengineering/view-resources'
/** /**
* @public * @public
@ -55,7 +55,7 @@ export async function updateTaskKanbanCategories (
viewlet.descriptor viewlet.descriptor
) )
if (res !== undefined) { if (res !== undefined) {
categories = res categories = concatCategories(res, categories)
break break
} }
} }
@ -78,7 +78,7 @@ export async function getTaskKanbanResultQuery (
if (viewOption.actionTarget !== 'query') continue if (viewOption.actionTarget !== 'query') continue
const queryOption = viewOption as ViewQueryOption const queryOption = viewOption as ViewQueryOption
const f = await getResource(queryOption.action) const f = await getResource(queryOption.action)
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, query) result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, result)
} }
return result return result
} }

View File

@ -24,9 +24,11 @@
Ref, Ref,
SortingOrder, SortingOrder,
TxOperations, TxOperations,
getObjectValue getObjectValue,
mergeQueries
} from '@hcengineering/core' } from '@hcengineering/core'
import notification from '@hcengineering/notification' import notification from '@hcengineering/notification'
import { getResource } from '@hcengineering/platform'
import { createQuery, getClient, reduceCalls, updateAttribute } from '@hcengineering/presentation' import { createQuery, getClient, reduceCalls, updateAttribute } from '@hcengineering/presentation'
import ui, { import ui, {
Button, Button,
@ -39,7 +41,14 @@
mouseAttractor, mouseAttractor,
resizeObserver resizeObserver
} from '@hcengineering/ui' } 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 { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
import { showMenu } from '../actions' import { showMenu } from '../actions'
@ -59,6 +68,8 @@
export let tableId: string | undefined = undefined export let tableId: string | undefined = undefined
export let readonly = false export let readonly = false
export let showFooter = false export let showFooter = false
export let viewOptionsConfig: ViewOptionModel[] | undefined = undefined
export let viewOptions: ViewOptions | undefined = undefined
export let totalQuery: DocumentQuery<Doc> | undefined = undefined export let totalQuery: DocumentQuery<Doc> | undefined = undefined
@ -117,6 +128,29 @@
: { ...(options?.sort ?? {}), [sortKey]: sortOrder } : { ...(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 ( const update = reduceCalls(async function (
_class: Ref<Class<Doc>>, _class: Ref<Class<Doc>>,
query: DocumentQuery<Doc>, query: DocumentQuery<Doc>,
@ -126,9 +160,11 @@
limit: number, limit: number,
options?: FindOptions<Doc> options?: FindOptions<Doc>
) { ) {
const p = await getResultQuery(query, viewOptionsConfig, viewOptions)
const resultQuery = mergeQueries(p, query)
loading += q.query( loading += q.query(
_class, _class,
query, resultQuery,
(result) => { (result) => {
if (sortingFunction !== undefined) { if (sortingFunction !== undefined) {
const sf = sortingFunction const sf = sortingFunction

View File

@ -16,7 +16,7 @@
import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@hcengineering/core' import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@hcengineering/core'
import { ActionContext } from '@hcengineering/presentation' import { ActionContext } from '@hcengineering/presentation'
import { FadeOptions, Scroller, tableSP } from '@hcengineering/ui' import { FadeOptions, Scroller, tableSP } from '@hcengineering/ui'
import { BuildModelKey } from '@hcengineering/view' import { BuildModelKey, ViewOptions, Viewlet } from '@hcengineering/view'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { focusStore, ListSelectionProvider, SelectDirection } from '../selection' import { focusStore, ListSelectionProvider, SelectDirection } from '../selection'
import { LoadingProps } from '../utils' import { LoadingProps } from '../utils'
@ -34,6 +34,8 @@
export let tableId: string | undefined = undefined export let tableId: string | undefined = undefined
export let fade: FadeOptions = tableSP export let fade: FadeOptions = tableSP
export let prefferedSorting: string = 'modifiedOn' 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. // If defined, will show a number of dummy items before real data will appear.
export let loadingProps: LoadingProps | undefined = undefined export let loadingProps: LoadingProps | undefined = undefined
@ -79,6 +81,8 @@
checked={$selection ?? []} checked={$selection ?? []}
{prefferedSorting} {prefferedSorting}
{tableId} {tableId}
{viewOptions}
viewOptionsConfig={viewlet?.viewOptions?.other}
selection={listProvider.current($focusStore)} selection={listProvider.current($focusStore)}
on:row-focus={(evt) => { on:row-focus={(evt) => {
listProvider.updateFocus(evt.detail) listProvider.updateFocus(evt.detail)

View File

@ -50,7 +50,7 @@ export async function OnStateUpdate (txes: TxCUD<Doc>[], control: TriggerControl
} }
} }
} }
return [] return result
} }
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type // eslint-disable-next-line @typescript-eslint/explicit-function-return-type