mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 12:47:45 +02:00
Add AllMatchValue function and related updates across multiple files (#10990)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -85,6 +85,7 @@ import { FieldChangedRollback, ToDoCancellRollback, ToDoCloseRollback } from './
|
||||
import {
|
||||
Absolute,
|
||||
Add,
|
||||
AllMatchValue,
|
||||
All,
|
||||
Append,
|
||||
Ceil,
|
||||
@@ -819,6 +820,7 @@ export default async () => ({
|
||||
EmptyValue,
|
||||
ExecutionInitiator,
|
||||
ExecutionStarted,
|
||||
AllMatchValue,
|
||||
FirstMatchValue,
|
||||
Filter,
|
||||
StringFromNumber,
|
||||
|
||||
@@ -63,6 +63,26 @@ export async function FirstMatchValue (
|
||||
}
|
||||
}
|
||||
|
||||
export async function AllMatchValue (
|
||||
value: any[],
|
||||
props: Record<string, any>,
|
||||
control: ProcessControl
|
||||
): Promise<any[] | undefined> {
|
||||
if (value == null) {
|
||||
return
|
||||
}
|
||||
if (!Array.isArray(value)) return value
|
||||
const { _class, ...otherProps } = props
|
||||
if (_class == null) return
|
||||
if (value.length === 0) return
|
||||
if (typeof value[0] === 'string') {
|
||||
const docs = await control.client.findAll(_class, { _id: { $in: value } })
|
||||
return matchQuery(docs, otherProps, core.class.Doc, control.client.getHierarchy(), true).map((p) => p._id)
|
||||
} else if (typeof value[0] === 'object') {
|
||||
return matchQuery(value, otherProps, core.class.Doc, control.client.getHierarchy(), true)
|
||||
}
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Array
|
||||
|
||||
Reference in New Issue
Block a user