mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Show/hide completed applicants in all viewlets (#7428)
This commit is contained in:
parent
962f3816b9
commit
fbb3471a49
@ -435,6 +435,26 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
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(
|
||||
view.class.Viewlet,
|
||||
core.space.Model,
|
||||
@ -479,9 +499,10 @@ export function createModel (builder: Builder): void {
|
||||
hiddenKeys: ['name', 'attachedTo'],
|
||||
sortable: true
|
||||
},
|
||||
baseQuery: {
|
||||
isDone: false,
|
||||
'$lookup.space.archived': false
|
||||
viewOptions: {
|
||||
groupBy: [],
|
||||
orderBy: [],
|
||||
other: [applicationDoneOption, hideApplicantsFromArchivedVacanciesOption]
|
||||
}
|
||||
},
|
||||
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 model: ViewOptionsModel = {
|
||||
groupBy: ['status', 'assignee', 'space', 'createdBy', 'modifiedBy'],
|
||||
@ -794,13 +796,8 @@ export function createModel (builder: Builder): void {
|
||||
{
|
||||
attachTo: recruit.class.Applicant,
|
||||
descriptor: task.viewlet.Kanban,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
baseQuery: {
|
||||
isDone: false,
|
||||
'$lookup.space.archived': false
|
||||
},
|
||||
viewOptions: {
|
||||
...applicantViewOptions(false, false),
|
||||
...applicantViewOptions(false, true),
|
||||
groupDepth: 1
|
||||
},
|
||||
options: {
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
type ViewQueryOption,
|
||||
type Viewlet
|
||||
} from '@hcengineering/view'
|
||||
import { getCategories, getCategorySpaces } from '@hcengineering/view-resources'
|
||||
import { getCategories, getCategorySpaces, concatCategories } from '@hcengineering/view-resources'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -55,7 +55,7 @@ export async function updateTaskKanbanCategories (
|
||||
viewlet.descriptor
|
||||
)
|
||||
if (res !== undefined) {
|
||||
categories = res
|
||||
categories = concatCategories(res, categories)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ export async function getTaskKanbanResultQuery (
|
||||
if (viewOption.actionTarget !== 'query') continue
|
||||
const queryOption = viewOption as ViewQueryOption
|
||||
const f = await getResource(queryOption.action)
|
||||
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, query)
|
||||
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user