mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-07 02:07:43 +02:00
UBERF-9062: Fix My applications for Recruit module (#7593)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -14,11 +14,10 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { PersonAccount } from '@hcengineering/contact'
|
||||
import { Class, Doc, DocumentQuery, getCurrentAccount, Ref, Status } from '@hcengineering/core'
|
||||
import { Class, Doc, DocumentQuery, getCurrentAccount, Ref, Status, WithLookup } from '@hcengineering/core'
|
||||
import { IntlString, Asset } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import tags, { TagCategory, TagElement } from '@hcengineering/tags'
|
||||
import { selectedTagElements } from '@hcengineering/tags-resources'
|
||||
import { Task } from '@hcengineering/task'
|
||||
import {
|
||||
Component,
|
||||
@@ -30,12 +29,11 @@
|
||||
SearchInput,
|
||||
Header
|
||||
} from '@hcengineering/ui'
|
||||
import { Viewlet, ViewletPreference, ViewOptions } from '@hcengineering/view'
|
||||
import { Viewlet, ViewletDescriptor, ViewletPreference, ViewOptions } from '@hcengineering/view'
|
||||
import {
|
||||
FilterBar,
|
||||
FilterButton,
|
||||
statusStore,
|
||||
TableBrowser,
|
||||
ViewletSelector,
|
||||
ViewletSettingButton
|
||||
} from '@hcengineering/view-resources'
|
||||
@@ -46,6 +44,7 @@
|
||||
export let labelTasks = task.string.Tasks
|
||||
export let icon: Asset
|
||||
export let config: [string, IntlString, object][] = []
|
||||
export let descriptors: Ref<ViewletDescriptor>[] | undefined = undefined
|
||||
|
||||
let search = ''
|
||||
const dispatch = createEventDispatcher()
|
||||
@@ -69,43 +68,22 @@
|
||||
|
||||
const client = getClient()
|
||||
|
||||
let category: Ref<TagCategory> | undefined = undefined
|
||||
const category: Ref<TagCategory> | undefined = undefined
|
||||
let loading = true
|
||||
let preference: ViewletPreference | undefined
|
||||
|
||||
let documentIds: Ref<Task>[] = []
|
||||
function updateResultQuery (
|
||||
search: string,
|
||||
documentIds: Ref<Task>[],
|
||||
doneStates: Status[],
|
||||
mode: string | undefined
|
||||
): void {
|
||||
function updateResultQuery (search: string, doneStates: Status[], mode: string | undefined): void {
|
||||
if (mode === 'assigned') {
|
||||
resultQuery.status = { $nin: doneStates.map((it) => it._id) }
|
||||
}
|
||||
if (documentIds.length > 0) {
|
||||
resultQuery._id = { $in: documentIds }
|
||||
}
|
||||
}
|
||||
|
||||
$: doneStates = $statusStore.array.filter(
|
||||
(it) => it.category === task.statusCategory.Lost || it.category === task.statusCategory.Won
|
||||
)
|
||||
|
||||
// Find all tags for object class with matched elements
|
||||
const query = createQuery()
|
||||
|
||||
$: query.query(tags.class.TagReference, { tag: { $in: $selectedTagElements } }, (result) => {
|
||||
documentIds = Array.from(
|
||||
new Set<Ref<Task>>(
|
||||
result
|
||||
.filter((it) => client.getHierarchy().isDerived(it.attachedToClass, _class))
|
||||
.map((it) => it.attachedTo as Ref<Task>)
|
||||
).values()
|
||||
)
|
||||
})
|
||||
const subscribedQuery = createQuery()
|
||||
function getSubscribed () {
|
||||
function getSubscribed (): void {
|
||||
subscribedQuery.query(
|
||||
_class,
|
||||
{ 'notification:mixin:Collaborators.collaborators': getCurrentAccount()._id },
|
||||
@@ -132,31 +110,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: updateResultQuery(search, documentIds, doneStates, mode)
|
||||
$: updateResultQuery(search, doneStates, mode)
|
||||
|
||||
let viewlet: Viewlet | undefined
|
||||
let viewlet: WithLookup<Viewlet> | undefined
|
||||
|
||||
let viewOptions: ViewOptions | undefined
|
||||
|
||||
function updateCategory (detail: { category: Ref<TagCategory> | null, elements: TagElement[] }) {
|
||||
category = detail.category ?? undefined
|
||||
selectedTagElements.set(Array.from(detail.elements ?? []).map((it) => it._id))
|
||||
}
|
||||
const handleChange = (evt: any) => {
|
||||
updateCategory(evt.detail)
|
||||
}
|
||||
$: viewOptionsConfig =
|
||||
mode === 'assigned'
|
||||
? viewlet?.viewOptions?.other
|
||||
: (viewlet?.viewOptions?.other ?? []).filter((it) => it.actionTarget !== 'query')
|
||||
</script>
|
||||
|
||||
<Header adaptive={'freezeActions'} hideActions={modeSelectorProps === undefined}>
|
||||
<svelte:fragment slot="beforeTitle">
|
||||
<ViewletSelector
|
||||
hidden
|
||||
bind:viewlet
|
||||
bind:preference
|
||||
bind:loading
|
||||
viewletQuery={{ attachTo: _class, descriptor: task.viewlet.StatusTable }}
|
||||
viewletQuery={{
|
||||
attachTo: _class,
|
||||
variant: { $exists: false },
|
||||
...(descriptors !== undefined ? { descriptor: { $in: descriptors } } : {})
|
||||
}}
|
||||
/>
|
||||
<ViewletSettingButton bind:viewOptions bind:viewlet />
|
||||
<ViewletSettingButton bind:viewOptions bind:viewlet {viewOptionsConfig} />
|
||||
</svelte:fragment>
|
||||
|
||||
<Breadcrumb {icon} label={labelTasks} size={'large'} isCurrent />
|
||||
@@ -166,7 +144,7 @@
|
||||
bind:value={search}
|
||||
collapsed
|
||||
on:change={() => {
|
||||
updateResultQuery(search, documentIds, doneStates, mode)
|
||||
updateResultQuery(search, doneStates, mode)
|
||||
}}
|
||||
/>
|
||||
<FilterButton {_class} adaptive={doubleRow} />
|
||||
@@ -179,18 +157,19 @@
|
||||
</Header>
|
||||
<FilterBar {_class} query={searchQuery} space={undefined} {viewOptions} on:change={(e) => (resultQuery = e.detail)} />
|
||||
|
||||
<Component is={tags.component.TagsCategoryBar} props={{ targetClass: _class, category }} on:change={handleChange} />
|
||||
|
||||
{#if viewlet}
|
||||
{#if loading}
|
||||
<Loading />
|
||||
{:else}
|
||||
<TableBrowser
|
||||
{_class}
|
||||
config={preference?.config ?? viewlet.config}
|
||||
options={viewlet.options}
|
||||
query={resultQuery}
|
||||
showNotification
|
||||
/>
|
||||
{/if}
|
||||
{#if loading || !viewlet || !viewlet?.$lookup?.descriptor?.component}
|
||||
<Loading />
|
||||
{:else}
|
||||
<Component
|
||||
is={viewlet.$lookup.descriptor.component}
|
||||
props={{
|
||||
_class,
|
||||
options: viewlet.options,
|
||||
config: preference?.config ?? viewlet.config,
|
||||
viewlet,
|
||||
viewOptions,
|
||||
viewOptionsConfig,
|
||||
query: resultQuery
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
export let space: Ref<Project> | undefined = undefined
|
||||
export let baseMenuClass: Ref<Class<Doc>> | undefined = undefined
|
||||
export let query: DocumentQuery<Task> = {}
|
||||
export let viewOptionsConfig: ViewOptionModel[] | undefined
|
||||
export let viewOptionsConfig: ViewOptionModel[] | undefined = undefined
|
||||
export let viewOptions: ViewOptions
|
||||
export let viewlet: Viewlet
|
||||
export let config: (string | BuildModelKey)[]
|
||||
|
||||
Reference in New Issue
Block a user