mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-20 08:37:53 +02:00
WhenFieldChanges trigger (#9913)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user