Skip to content

Commit

Permalink
Merge pull request #161 from mercedes-benz/VULCAN-1004/TableActionRules
Browse files Browse the repository at this point in the history
fix: rule evaluator bug
  • Loading branch information
m-o-n-i-s-h authored Dec 11, 2024
2 parents b760424 + 26150cf commit 6671ace
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/extensions/styling/StyleRuleEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,20 @@ export const evaluateRulesOnDict = (dict, rules, customizations) => {
}
for (const [index, rule] of rules.entries()) {
// Only check customizations that are specified
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;
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;
}
}
}
}
// If no rules are met, return not found (index=-1)
return -1;
}

};

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

0 comments on commit 6671ace

Please sign in to comment.