tachybase_todo/packages/plugins/workflow/src/client/utils.ts
Junyi ea4d4ac062
feat(plugin-workflow) config preload associations in triggers and nodes (#1548)
* feat(plugin-workflow): add preload associations for triggers and nodes

* feat(plugin-workflow): add appends parameter to schedule trigger

* fix(plugin-workflow): fix import

* fix(plugin-workflow): fix component injection

* test(plugin-workflow): add test case
2023-03-10 16:36:58 +08:00

37 lines
831 B
TypeScript

export function linkNodes(nodes): void {
const nodesMap = new Map();
nodes.forEach(item => nodesMap.set(item.id, item));
for (let node of nodesMap.values()) {
if (node.upstreamId) {
node.upstream = nodesMap.get(node.upstreamId);
}
if (node.downstreamId) {
node.downstream = nodesMap.get(node.downstreamId);
}
}
}
export function isValidFilter(condition) {
const group = condition.$and || condition.$or;
if (!group) {
return false;
}
return group.some(item => {
if (item.$and || item.$or) {
return isValidFilter(item);
}
const [name] = Object.keys(item);
if (!name || !item[name]) {
return false;
}
const [op] = Object.keys(item[name]);
if (!op || typeof item[name][op] === 'undefined') {
return false;
}
return true;
});
}