WhenFieldChanges trigger (#9913)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-09-23 00:01:24 +07:00
committed by GitHub
parent 9ae9453a52
commit e089e201f1
28 changed files with 447 additions and 67 deletions
@@ -81,7 +81,7 @@ export async function CheckSubProcessesDone (control: ProcessControl, execution:
return res === undefined
}
export function OnCardUpdateCheck (
export function MatchCardCheck (
control: ProcessControl,
execution: Execution,
params: Record<string, any>,
@@ -94,6 +94,23 @@ export function OnCardUpdateCheck (
return res.length > 0
}
export function FieldChangedCheck (
control: ProcessControl,
execution: Execution,
params: Record<string, any>,
context: Record<string, any>
): boolean {
if (context.card === undefined) return false
const process = control.client.getModel().findObject(execution.process)
if (process === undefined) return false
if (context.operations === undefined) return false
const changedFields = Object.keys(context.operations)
const target = Object.keys(params)[0]
if (!changedFields.includes(target)) return false
const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true)
return res.length > 0
}
export function CheckTime (control: ProcessControl, execution: Execution, params: Record<string, any>): boolean {
if (params.value === undefined) return false
return params.value <= Date.now()