Skip to content

Commit

Permalink
Merge pull request #162 from mercedes-benz/revert-161-VULCAN-1004/Tab…
Browse files Browse the repository at this point in the history
…leActionRules

Revert "fix: rule evaluator bug"
  • Loading branch information
m-o-n-i-s-h authored Dec 11, 2024
2 parents 6671ace + 14e1ec4 commit dfba1dc
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/extensions/styling/StyleRuleEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,27 @@ export const evaluateRulesOnDict = (dict, rules, customizations) => {
}
for (const [index, rule] of rules.entries()) {
// Only check customizations that are specified
if (customizations.includes(rule.customization)) {
// if the row contains the specified field...
if (dict[rule.field] !== undefined && dict[rule.field] !== null) {
const realValue = dict[rule.field].low ? dict[rule.field].low : dict[rule.field];
const ruleValue = rule.value;
if (evaluateCondition(realValue, rule.condition, ruleValue)) {
return index;
}
}
}
return evaluateSingleRuleOnDict (dict, rule, index, customizations)
}
// If no rules are met, return not found (index=-1)
return -1;
};

export const evaluateSingleRuleOnDict = (dict, rule, ruleIndex, customizations) => {
if (customizations.includes(rule.customization)) {
// if the row contains the specified field...
if (dict[rule.field] !== undefined && dict[rule.field] !== null) {
const realValue = dict[rule.field].low ? dict[rule.field].low : dict[rule.field];
const ruleValue = rule.value;
if (evaluateCondition(realValue, rule.condition, ruleValue)) {
return ruleIndex;
}
}
}
return -1;
}


/**
* Evaluates the specified rule set on a node object returned by the Neo4j driver.
* @param node - the node representation returned by the Neo4j driver.
Expand Down

0 comments on commit dfba1dc

Please sign in to comment.