Skip to content

feat: per-column filter operators, default operator and compare options (#373) - #511

Open
michaelstonis wants to merge 1 commit into
mainfrom
feat/373-filter-operator-settings
Open

michaelstonis wants to merge 1 commit into
mainfrom
feat/373-filter-operator-settings

Conversation

@michaelstonis

Copy link
Copy Markdown
Contributor

Closes #373.

Changes

Per-column filter settings on KumikoColumn (a Core object, so MAUI and Uno XAML and code get them without host properties).

  • KumikoColumn is now partial; the new members live in KumikoColumn.FilterOptions.cs. The only edit to KumikoColumn.cs is the partial keyword and re-parsing AllowedFilterOperatorsString when ColumnType changes.
  • AllowedTextFilterOperators, AllowedNumericFilterOperators, AllowedDateFilterOperators: the operators the filter popup lists, in order. Null or empty offers all.
  • AllowedFilterOperatorsString: XAML form ("Equals,StartsWith"), case-insensitive, parsed with generic Enum.TryParse<TEnum> (AOT-safe) against the enum of ColumnType (Text/ComboBox/Picker text; Numeric/ProgressBar numeric; Date/DateTime/Time date). An unknown name, a numeric string or a column type without operators throws ArgumentException at assignment. When ColumnType changes afterward the names are parsed again leniently (names that no longer fit are dropped).
  • DefaultTextFilterOperator, DefaultNumericFilterOperator, DefaultDateFilterOperator, CreateDefaultFilterCondition(): an explicit default is honored as given; with none, the stock operator (Contains / Equals / Equals) applies, or the first allowed operator when the allowed list does not contain it.
  • FilterCompareOptions: replaces KumikoSource.StringCompareOptions for the column's conditions and its value list (culture still the source's). FilterSpec carries the per-column comparer; PrepareFilters (foreground and background builds, so the worker captures it with the other filter state), ViewBuilder.Passes, GetUniqueColumnValues and FilterDescription.Evaluate use it. The comparer is cached on the column, keyed by culture and options, so a rebuild does not allocate one per filter; no per-row allocation was added. Changing the option rebuilds an active filter.
  • DrawnFilterPopup.Conditions.cs (small, focused edit): the operator drop-downs list the allowed operators plus the operators of conditions the column already has (so a condition set from code is never changed silently), and start on the default operator. FilterConditionTypes gained the helpers.
  • Enforcement: UI only. SetColumnFilter does not reject disallowed operators (code is trusted); documented in the XML docs, README and CHANGELOG.
  • Public API added (PublicAPI.Unshipped.txt, 17 lines): the properties above and CreateDefaultFilterCondition() on KumikoColumn.
  • Docs: README "Filtering" section, CHANGELOG entry.
  • Not touched: KumikoRenderer, KumikoInputController, the hit tester.

Acceptance criteria

  • New KumikoColumn properties with change notification and XAML string form on MAUI and Uno. Notification is tested; the string form is on KumikoColumn itself, shared by both hosts. Nullable-enum properties (DefaultTextFilterOperator="StartsWith", FilterCompareOptions="None") in Uno XAML were not verified in a running head; the string form covers operator lists either way.
  • FilterCompareOptions changes how that column's conditions and value list compare, without affecting other columns, in foreground and background rebuilds (tests for both).
  • CreateDefaultFilterCondition honors the default operators.
  • Behavior tests in tests/KumikoUI.Core.Tests: new ColumnFilterOptionsTests (defaults, default condition, notification, string parsing and its errors, case sensitivity for conditions, value list and GetUniqueColumnValues, comparer cache, popup operator lists and defaults), a background case in BackgroundRebuildTests. Existing FilterConditionTests and FilterDescriptionTests pass unchanged; the filter-description behavior is covered in the new file.
  • XML docs on every new public member; PublicAPI.Unshipped.txt updated (the script emptied the file in this worktree, so the 17 lines were added by hand from the RS0016 list and sorted).
  • README "Filtering" section updated; CHANGELOG entry under Unreleased.
  • No allocations added to the per-frame render path or per row during filtering.
  • Open questions in the issue (restricting Empty/NotEmpty is possible through the allowed list; no AllowValueListFilter) were left as scope cuts.

Verification

  • dotnet build src/KumikoUI.Core: 0 warnings, 0 errors
  • dotnet build src/KumikoUI.SkiaSharp: 0 errors
  • dotnet build src/KumikoUI.Maui -f net10.0-maccatalyst: 0 errors
  • dotnet build src/KumikoUI.Uno -f net10.0-desktop: 0 errors
  • dotnet test tests/KumikoUI.Core.Tests: 4385 passed, 5 skipped, 0 failed
  • dotnet test tests/KumikoUI.Uno.Tests: 321 passed
  • dotnet test tests/KumikoUI.Maui.Tests: 449 passed

Comment on lines +87 to +88
foreach (var op in keep)
if (op != null && !allowed.Contains(op)) allowed.Add(op);
Comment on lines +96 to +97
foreach (var op in list)
if (!result.Contains(op)) result.Add(op);
Comment on lines +174 to +187
foreach (var part in text.Split(','))
{
var name = part.Trim();
if (name.Length == 0) continue;
if (char.IsLetter(name[0]) && Enum.TryParse<TEnum>(name, ignoreCase: true, out var value) && Enum.IsDefined(value))
{
if (!list.Contains(value)) list.Add(value);
}
else if (strict)
{
throw new ArgumentException(
$"'{name}' is not a {typeof(TEnum).Name} operator.");
}
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Filtering: per-column allowed operators, default operator and case sensitivity

2 participants