Files
DiceCloud/app/imports/api/engine/computation/buildComputation/computeToggleDependencies.js
Stefan Zermatten e34f29f952 Computations now occupy their own nodes on the dependency graph
This mitigates most issues with properties having self-loops, 
particularly in cases like Strength where the value `strength` is used 
in the description of Strength
2021-12-07 21:05:24 +02:00

18 lines
604 B
JavaScript

import walkDown from '/imports/api/engine/computation/utility/walkdown.js';
export default function computeToggleDependencies(node, dependencyGraph){
const prop = node.node;
// Only for toggles that aren't inactive and aren't set to enabled or disabled
if (
prop.inactive ||
prop.type !== 'toggle' ||
prop.disabled ||
prop.enabled
) return;
walkDown(node.children, child => {
child.node._computationDetails.toggleAncestors.push(prop);
// The child nodes depend on the toggle condition compuation
dependencyGraph.addLink(child.node._id, prop._id, 'toggle');
});
}