mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
TSK-1189: Fix showing all available categories (#2987)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
db4d240f0a
commit
4f36208880
@ -42,6 +42,7 @@
|
||||
ActionContext,
|
||||
focusStore,
|
||||
getCategories,
|
||||
getCategorySpaces,
|
||||
getGroupByValues,
|
||||
getPresenter,
|
||||
groupBy,
|
||||
@ -167,9 +168,15 @@
|
||||
const categoryFunc = viewOption as CategoryOption
|
||||
if (viewOptions[viewOption.key] ?? viewOption.defaultValue) {
|
||||
const categoryAction = await getResource(categoryFunc.action)
|
||||
|
||||
const spaces = getCategorySpaces(categories)
|
||||
if (space !== undefined) {
|
||||
spaces.push(space)
|
||||
}
|
||||
|
||||
const res = await categoryAction(
|
||||
_class,
|
||||
space ? { space } : {},
|
||||
spaces.length > 0 ? { space: { $in: Array.from(spaces.values()) } } : {},
|
||||
groupByKey,
|
||||
update,
|
||||
queryId,
|
||||
|
@ -55,6 +55,7 @@
|
||||
ActionContext,
|
||||
focusStore,
|
||||
getCategories,
|
||||
getCategorySpaces,
|
||||
getGroupByValues,
|
||||
getPresenter,
|
||||
groupBy,
|
||||
@ -193,9 +194,14 @@
|
||||
const categoryFunc = viewOption as CategoryOption
|
||||
if (viewOptions[viewOption.key] ?? viewOption.defaultValue) {
|
||||
const categoryAction = await getResource(categoryFunc.action)
|
||||
|
||||
const spaces = getCategorySpaces(categories)
|
||||
if (space !== undefined) {
|
||||
spaces.push(space)
|
||||
}
|
||||
const res = await categoryAction(
|
||||
_class,
|
||||
space !== undefined ? { space } : {},
|
||||
spaces.length > 0 ? { space: { $in: Array.from(spaces.values()) } } : {},
|
||||
groupByKey,
|
||||
update,
|
||||
queryId,
|
||||
|
@ -647,6 +647,18 @@ export async function getCategories (
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getCategorySpaces (categories: CategoryType[]): Array<Ref<Space>> {
|
||||
return Array.from(
|
||||
(categories.filter((it) => typeof it === 'object') as StatusValue[]).reduce<Set<Ref<Space>>>((arr, val) => {
|
||||
val.values.forEach((it) => arr.add(it.space))
|
||||
return arr
|
||||
}, new Set())
|
||||
)
|
||||
}
|
||||
|
||||
export function concatCategories (arr1: CategoryType[], arr2: CategoryType[]): CategoryType[] {
|
||||
const uniqueValues: Set<string | number | undefined> = new Set()
|
||||
const uniqueObjects: Map<string | number, StatusValue> = new Map()
|
||||
|
@ -139,14 +139,6 @@ export async function showEmptyGroups (
|
||||
const resQuery: DocumentQuery<Status> = {}
|
||||
if (space !== undefined) {
|
||||
resQuery.space = space
|
||||
} else {
|
||||
const spaceRefs = Array.from(new Set(statusList.map((p) => p.space)))
|
||||
const spaces = await client.findAll(
|
||||
core.class.Space,
|
||||
{ _id: { $in: spaceRefs }, archived: false },
|
||||
{ projection: { _id: 1 } }
|
||||
)
|
||||
resQuery.space = { $in: spaces.map((p) => p._id) }
|
||||
}
|
||||
if (st !== undefined) {
|
||||
resQuery._id = st
|
||||
|
Loading…
Reference in New Issue
Block a user