Skip to content

splitWhereByReadability

splitWhereByReadability(node, isFieldReadable): SplitWhereByReadability

Defined in: packages/core/src/collections/savedListViews/whereReadability.ts:79

Splits a where tree into the portion safe to show the caller as a filter chip (SplitWhereByReadability.visible) and a count of the leaf conditions that are not (hiddenCount) — the shared computation behind a saved view’s hidden-filter badge, used for BOTH a config/ default view’s declared where (toClientSavedListViewConfig) and a shared view’s own saved where (@vexcms/react’s useSavedListViews.ts), so neither can drift from the other about what “hidden” means. Replaces the earlier “any unreadable field anywhere in the tree hides the WHOLE tree” rule — a condition on a field the caller CAN read is always shown, whether or not some OTHER sibling condition in the same view is on a field they can’t.

An and node splits leaf-by-leaf: every readable child survives into visible (re-wrapped in a new and when more than one survives, or returned bare when exactly one does), every unreadable child is dropped and counted. An or/not node is NOT split internally — showing just one branch of an or (or the content of a not) as if it were the whole condition would misrepresent what the query actually matches — so the WHOLE node counts as hidden the moment ANY field it references is unreadable, and is shown unchanged (every leaf counted visible, 0 hidden) when every field it references is readable. A bare leaf is either fully visible or fully hidden (counting 1).

VexWhereNodeOf<unknown>

The where tree, or a branch of it during recursion.

(field) => boolean

Whether the current caller may read one field.

SplitWhereByReadability

The visible subtree (if any) and the hidden leaf count.