diff --git a/packages/core/src/query.ts b/packages/core/src/query.ts index a4811cab99..d42a81011c 100644 --- a/packages/core/src/query.ts +++ b/packages/core/src/query.ts @@ -20,7 +20,7 @@ export function findProperty (objects: Doc[], propertyKey: string, value: any): const result: Doc[] = [] for (const object of objects) { const val = getObjectValue(propertyKey, object) - if (val === value || isArrayValueCheck(val, value)) { + if (val === value || (val == null && value == null) || isArrayValueCheck(val, value)) { result.push(object) } } diff --git a/plugins/view-resources/src/utils.ts b/plugins/view-resources/src/utils.ts index 975d3d1bed..e04ac2ba3d 100644 --- a/plugins/view-resources/src/utils.ts +++ b/plugins/view-resources/src/utils.ts @@ -36,7 +36,8 @@ import core, { Status, StatusManager, StatusValue, - TxOperations + TxOperations, + WithLookup } from '@hcengineering/core' import type { IntlString } from '@hcengineering/platform' import { getResource } from '@hcengineering/platform' @@ -622,8 +623,17 @@ export async function groupByStatusCategories ( const existingCategories: StatusValue[] = [] const statusMap = new Map() + const usedSpaces = new Set>() + const statusesList: Array> = [] for (const v of categories) { const status = mgr.byId.get(v) + if (status !== undefined) { + statusesList.push(status) + usedSpaces.add(status.space) + } + } + + for (const status of statusesList) { if (status !== undefined) { let fst = statusMap.get(status.name.toLowerCase().trim()) if (fst === undefined) { @@ -632,7 +642,7 @@ export async function groupByStatusCategories ( (it) => it.ofAttribute === status.ofAttribute && it.name.toLowerCase().trim() === status.name.toLowerCase().trim() && - (categories.includes(it._id) || it.space === status.space) + (categories.includes(it._id) || usedSpaces.has(it.space)) ) .sort((a, b) => a.rank.localeCompare(b.rank)) fst = new StatusValue(status.name, status.color, statuses)