Skip to content

Commit

Permalink
refactor return value
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Oct 15, 2024
1 parent cc6555e commit 5a3401a
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/utils/strategyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,21 @@ export function formatStrategyValues(
if (strategy === SHOW_CHILD) {
return values.filter(key => {
const entity = keyEntities[key];

if (
entity &&
entity.children &&
entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) &&
entity.children.every(
return (
!entity ||
!entity.children ||
!entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) ||
!entity.children.every(
({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]),
)
) {
return false;
}
return true;
);
});
}
if (strategy === SHOW_PARENT) {
return values.filter(key => {
const entity = keyEntities[key];
const parent = entity ? entity.parent : null;

if (parent && !isCheckDisabled(parent.node) && valueSet.has(parent.key)) {
return false;
}
return true;
return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
});
}
return values;
Expand Down

0 comments on commit 5a3401a

Please sign in to comment.