Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Oct 15, 2024
1 parent 5c72bb5 commit 02f25e5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/utils/strategyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function formatStrategyValues(
): SafeKey[] {
const valueSet = new Set(values);

if (strategy === SHOW_CHILD) {
return values.filter(key => {
const strategyHandlers = {
[SHOW_CHILD]: (key: SafeKey) => {
const entity = keyEntities[key];
return (
!entity ||
Expand All @@ -28,14 +28,14 @@ export function formatStrategyValues(
({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]),
)
);
});
}
if (strategy === SHOW_PARENT) {
return values.filter(key => {
},
[SHOW_PARENT]: (key: SafeKey) => {
const entity = keyEntities[key];
const parent = entity ? entity.parent : null;
const parent = entity?.parent;
return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
});
}
return values;
},
[SHOW_ALL]: () => true,
};

return values.filter(strategyHandlers[strategy] || strategyHandlers[SHOW_ALL]);
}

0 comments on commit 02f25e5

Please sign in to comment.