Repository navigation
feat: add cross-column filter expressions with nested AND/OR groups (#408) - #519
Open
michaelstonis wants to merge 1 commit into
Open
michaelstonis wants to merge 1 commit into
michaelstonis wants to merge 1 commit into
Conversation
…408) KumikoFilterExpression trees of groups and column conditions, evaluated with the column filters and the predicate in synchronous and background builds, cleared by ClearAllFilters, saved in KumikoLayoutState, and exposed as FilterExpression on the MAUI and Uno grids. The drawn filter builder is not part of this change.
Open
10 tasks
| }; | ||
| if (copy._condition == null) | ||
| { | ||
| var children = (ChildCollection)copy.Children; |
|
|
||
| source.SetFilterExpression(expression); | ||
| expression.Children.Add(Text(nameof(Row.Region), TextFilterOperator.Equals, "East")); // not seen by the source | ||
| ((FilterCondition)expression.Children[0].Condition!).Value = "North"; |
Comment on lines
+75
to
+76
| foreach (var child in state.Children) | ||
| if (child != null) node.Children.Add(ToNode(child, depth + 1)); |
Comment on lines
+95
to
+102
| foreach (var col in _columns) | ||
| { | ||
| if (!_filterExpressionKeys.Contains(col.LayoutKey)) continue; | ||
| // A value accessor or the item itself (empty path) may depend on any property. | ||
| if (col.ValueAccessor != null || string.IsNullOrEmpty(col.PropertyName) || | ||
| PropertyPathAffected(col.PropertyName, propName)) | ||
| return true; | ||
| } |
Comment on lines
+185
to
+189
| foreach (var child in node.Children) | ||
| { | ||
| if (Capture(child, columns, readers, comparer, forWorker) is { } spec) | ||
| (children ??= new()).Add(spec); | ||
| } |
Comment on lines
+224
to
+227
| foreach (var child in _children) | ||
| { | ||
| if (!child.Evaluate(item)) { result = false; break; } | ||
| } |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #408.
Changes
Stage 1 of the issue, the model and its evaluation, plus host properties, layout state, docs and tests. The drawn builder popup (
DrawnFilterBuilder,ShowFilterBuilder/CloseFilterBuilder,FilterBuilderOpened/Closed) is held until Foundations #446/#448 land, because it is hosted by the input controller. Nothing undersrc/KumikoUI.Core/Input/and noKumikoRenderer*.csfile is touched.KumikoFilterExpression(new,Models/KumikoFilterExpression.cs): one node type. It is a group (CombinationAnd/Or,IsNegated,Children) or, whenConditionis set, a condition onColumnKey(aFilterCondition).IsGrouptells them apart.IsNegatedworks on a condition too. Factories:And(...),Or(...),Not(child),Where(columnKey, condition).Clone()makes a deep, editable copy.IsReadOnlyis true for the copy a source keeps: its setters andChildrenthrow on change. Null children are rejected.MaxDepth(16) is the depth limit and also catches a tree that contains itself.KumikoSource(new partialKumikoSource.FilterExpression.cs):FilterExpression(the read-only copy),SetFilterExpression(expression)(copies the tree, rebuilds once, raisesFilterExpressionChanged) andFilterExpressionChangedwithKumikoFilterExpressionChangedEventArgs(OldExpression,NewExpression).FilterExpressionSpectree. Columns are resolved byKey, elsePropertyName, as layout state does, and each referenced column gets oneItemReaderthat its conditions share. A worker build copies the conditions, so background builds never read the live tree or the columns. Each condition is evaluated by its column'sColumnType, the same way a column filter's conditions are. A Boolean condition matches cells equal to itsValue(the column filter's Boolean condition passes every row, so it could not be reused). A condition on an unknown column is inactive, and so is a group with no active children; inactive nodes are dropped from their group, so an empty group passes every row, negated or not. The expression is ANDed inViewBuilder.Passes(new optional parameter), which covers the foreground and background rebuilds, the incremental insert path andGetUniqueColumnValues.ItemPropertyImpacttreats properties read by referenced columns as row-affecting. A referenced column'sValueAccessororColumnTypechange rebuilds, and so does any column'sKeyorPropertyNamechange while an expression is set. Columns are matched at every rebuild, so an expression set before its columns exist (for example generated ones) applies once they appear.ClearAllFiltersclears the expression too and raisesFilterExpressionChanged.IsFilteredcounts an expression that has an active condition.KumikoLayoutState.FilterExpression(KumikoFilterExpressionLayoutState) is one class for both node kinds (Combination,IsNegated,Children,ColumnKey,ConditionasKumikoFilterConditionLayoutState), so the existing source-generatedKumikoLayoutJsonContexthandles it with no polymorphism. The type is reached through the property graph, so no registration line was needed.CurrentVersionstays 1.Capturewrites an empty group when the source has no expression, so applying a captured layout clears one; null (a layout saved before this change) leaves the current expression in place.FilterExpressionbindable property on MAUI and a dependency property on Uno, plus aFilterExpressionChangedevent on both (KumikoDataGrid.FilterExpression.cs). The property holds the source's read-only copy and follows the source (ClearAllFilters,ApplyLayoutState).KumikoComparer, chosen in one seam,FilterExpressionSpec.ConditionComparer(column, comparer), which returns the build's comparer for now. When Filtering: per-column allowed operators, default operator and case sensitivity #373 merges, that line becomes the column's filter comparer (the one Filtering: per-column allowed operators, default operator and case sensitivity #373 caches per culture and options), and expression conditions then follow the column's case sensitivity in both build paths. Both branches add an argument toViewBuilder.Passesand touchPrepareFilterscallers, so expect a small textual merge there.PublicAPI.Unshipped.txt).eng/update-public-api.shempties the Core file in this environment, so the lines were added by hand from the RS0016 list, in sorted order.Acceptance criteria
tests/KumikoUI.Core.Tests(newFilterExpressionTests.cs, 27 tests): nested AND/OR/NOT evaluation; combination with column filters and the predicate; unknown column keys; key vs property-name matching; columns added later; Boolean and Date conditions; background and synchronous builds agree; property changes on referenced columns rebuild (and unreferenced ones only redraw); column accessor change rebuilds; copy and read-only semantics; depth and cycle limit; JSON round trip; old layouts leave the expression;ClearAllFilters.DrawnFilterBuilder: not done, held for Kernel: split the grid frame into reusable painters and let panes share scroll state #446/Kernel: multi-pointer gesture recognizer (pan, pinch, wheel zoom about a point, fling) #448 (builder UI).FilterExpressionis on both hosts (MAUI mapping tests added; the Uno test project does not construct the grid, and the Uno build passes).ShowFilterBuilderand value-editor text input are held for Kernel: split the grid frame into reusable painters and let panes share scroll state #446/Kernel: multi-pointer gesture recognizer (pan, pinch, wheel zoom about a point, fling) #448.PublicAPI.Unshipped.txtupdated (Core, Maui, Uno).RenderAllocationTestspasses; the "builder open" case is held with the builder.Verification
dotnet build src/KumikoUI.Core: Build succeeded, no warningsdotnet build src/KumikoUI.SkiaSharp: Build succeededdotnet build src/KumikoUI.Maui -f net10.0-maccatalyst: Build succeededdotnet build src/KumikoUI.Uno -f net10.0-desktop: Build succeeded (only the existing Uno0001 warnings in other files)dotnet test tests/KumikoUI.Core.Tests: 4388 passed, 5 skipped, 0 faileddotnet test tests/KumikoUI.Maui.Tests: 451 passeddotnet test tests/KumikoUI.Uno.Tests: 321 passeddotnet run --project eng/DocsSnippets -c Release, thendotnet build tests/KumikoUI.Docs.Snippets.Uno -f net10.0-desktop -c Releaseanddotnet build tests/KumikoUI.Docs.Snippets.Maui -f net10.0-maccatalyst -c Release: both succeeded (the new README snippet compiles on both hosts)