Repository navigation
feat: remote view contract that pushes sort, filter, grouping and row windows to the server (#359) - #506
Open
michaelstonis wants to merge 2 commits into
Open
feat: remote view contract that pushes sort, filter, grouping and row windows to the server (#359)#506michaelstonis wants to merge 2 commits into
michaelstonis wants to merge 2 commits into
Conversation
Comment on lines
+497
to
+498
| foreach (var item in _items) | ||
| if (item != null) list.Add(item); |
Comment on lines
+519
to
+524
| foreach (var item in node.Items) | ||
| { | ||
| if (item == null) continue; | ||
| combined.Add(item); | ||
| count++; | ||
| } |
Comment on lines
+615
to
+628
| foreach (var group in groups) | ||
| { | ||
| if (group == null) continue; | ||
| nodes.Add(new RemoteGroupNode | ||
| { | ||
| Tree = this, | ||
| Key = group.Key, | ||
| ItemCount = Math.Max(0, group.ItemCount), | ||
| Summaries = group.Summaries, | ||
| Level = level, | ||
| Parent = parent, | ||
| KeyPath = new GroupKeyPath(parent?.KeyPath, property, group.Key), | ||
| }); | ||
| } |
Comment on lines
+132
to
+133
| foreach (var column in columns) | ||
| if (keys.Add(KumikoRemoteResult.SummaryKey(column))) result.Add(column); |
Comment on lines
+37
to
+40
| if (texts.TryGetValue(displayText, out int seen)) | ||
| texts[displayText] = ordinal = seen + 1; | ||
| else | ||
| texts[displayText] = 1; |
Comment on lines
+107
to
+113
| foreach (var row in _s.GroupSummaries) | ||
| { | ||
| if (row.Levels == GroupSummaryLevels.Innermost && !isInnermost) continue; | ||
| specs.Add(row); | ||
| rows.Add(SummaryText.BuildRowFromValues(row.Name, row.Title, row.Columns, | ||
| d => KumikoRemoteResult.Lookup(values, d), _s.Comparer.Culture, _s.Strings)); | ||
| } |
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.
Closes #359.
Changes
Adds one data-layer contract for server-side views: the grid's sort, filters, grouping and summaries are sent to an
IKumikoRemoteSource, and the grid shows only the rows that come back. It is wired intoKumikoSourceand the view pipeline (ViewBuilder). Renderer, input controller and hit tester are not touched.Query hook (works without a remote source too)
KumikoQuery(Sorts,Filters,Groups,IsEmpty,FindFilter,Empty) andKumikoSortDescriptor(PropertyName, Direction), with the names from Spec: paging and DataTable / dictionary / dynamic row sources #107 section 5.9. A column with noPropertyNamesorts under itsKey, sinceKumikoColumnhas noId.KumikoSource.GetQuery()andKumikoSource.QueryChanged(KumikoQueryChangedEventArgs:Query,ChangesasKumikoQueryChangesflags). It is raised once after a sort, filter or group change, after the*Changedevents, and once perBeginUpdatebatch. A canceled change or a no-op raises nothing.Remote contract (
KumikoUI.Core.Data)IKumikoRemoteSourcehasCapabilities(KumikoRemoteCapabilities:Sort,Filter,Group,Summaries,TotalCount,DistinctValues) andQueryAsync(KumikoRemoteRequest, CancellationToken).KumikoRemoteRequestcarries:QuerySkipandTakeGroupPathandGroupLevelReturnsGroupsSummariesandIncludeTotalCountReason(KumikoRemoteRequestReason)KumikoRemoteResulthasItems,TotalCount,GroupsandSummaries.KumikoRemoteResult.SummaryKey(...)builds keys like"Amount:Sum", compared ignoring case.KumikoRemoteGroup(Key, ItemCount, Summaries)is one server group.KumikoRemoteSourceis a delegate implementation, with an optional distinct-values delegate.IKumikoDistinctValuesSourceis the optional interface for a filter's value list.KumikoRemoteView(KumikoSource.Remote) is the controller, built likeKumikoIncrementalLoader. It exposes:State(KumikoRemoteState:Idle,Loading,Failed),IsLoading,LastError,ErrorText,LastRequestTotalCount,SummariesWindowStart,WindowSize(defaultDefaultWindowSize= 200),SetWindow(start, size)ReloadAsync(),WhenIdleAsync(),GetDistinctValuesAsync(column)StateChanged,QueryFailed(KumikoRemoteQueryFailedEventArgs, with a settableErrorText),ResultAppliedKumikoSource.RemoteSourceturns remote mode on. While it is set:SynchronizationContext).QueryFailed.SetFilter(predicate)throws under a source that filters, and aGroupDescription.KeySelectorthrows under a source that groups, both on the setter and on later calls.RemoveItemsandReorderRowreportNotSupportedSource.TotalCountis exposed. WithSummaries, table, group and caption summaries show the server's values (SummaryText.BuildRowFromValuesandBuildCaptionFromValues) instead of aggregating, and nothing updates in place.Group, the top-level request returnsGroups.ViewBuilder.BuildRemoteGroupsdraws them as group headers with the server's counts and summaries, keyed byGroupKeyPath, so expand state andToggleGroupExpansionwork as before. A group's rows, or its child groups for nested levels, are requested with itsGroupPathwhen it is first expanded. Collapsed groups load nothing. A failed group request is retried when the group is expanded again. Old groups stay on screen until a new grouped result arrives.Hosts (MAUI and Uno, same names)
RemoteSource,RemoteWindowSize(200), read-onlyRemoteState,RemoteQueryFailed(sender is the grid) andReloadRemoteAsync().KumikoAnnouncements.RemoteStateChanged. New strings:AnnounceRemoteLoading,AnnounceRemoteLoaded,RemoteLoadFailedandAnnounceRemoteLoadFailed.Samples and docs
samples/Shared/RemoteQueryOrders.cs) that sorts, filters, groups and totals 5,000 orders. The page has latency, a forced failure, row-window paging, grouping by region and Reload.Small edits to existing code:
KumikoIncrementalLoaderreturns early in remote mode.KumikoSource.SetItemsis split intoSetItemsCore.EndUpdateraisesQueryChangedafter the view notification.CaptureBuildSettingsleaves out what the server does.ItemPropertyImpactno longer rebuilds for a server-side sort, filter or group key.Acceptance criteria
IKumikoRemoteSourcebehaves exactly as today. All 4,398 existing and new Core tests pass, with no change to local behavior apart from the newQueryChangedevent.QueryFailed.tests/KumikoUI.Core.Testswith a fake remote source. 37 tests inRemote/RemoteViewTests.cscover latency, cancellation, failure, retry, coalescing, marshaling to the UI thread, grouping, summaries and a synchronous source. There are 3 host tests inKumikoUI.Maui.Tests.KumikoUI.Mauilibrary builds.PublicAPI.Unshipped.txtupdated. Core, Maui and Uno are updated. On this machineeng/update-public-api.shemptied the file instead of filling it, so the entries were added from the RS0016 diagnostics and kept sorted.RenderAllocationTestspass.Deferred to #360, as scoped: placeholder rows, scroll-driven window fetching, the page cache,
IsRowLoaded, scrollbar extent fromTotalCount, and windows beyond the first one inside a server group. Also deferred: the drawn filter popup does not callGetDistinctValuesAsyncyet and still lists loaded values. That wiring belongs with #353. The visual loading indicator for remote loads is #327.Verification
dotnet build src/KumikoUI.Core(Debug and Release): succeeded, 0 warnings.dotnet build src/KumikoUI.SkiaSharp: succeeded.dotnet build src/KumikoUI.Maui -f net10.0-maccatalyst: succeeded, 0 warnings.dotnet build src/KumikoUI.Uno -f net10.0-desktop: succeeded. The only warnings are the existing Uno0001 ones inEditing.csandInput.cs.dotnet build samples/SampleApp.Uno -f net10.0-desktop: succeeded.dotnet build samples/SampleApp.Maui -f net10.0-maccatalyst: restore fails with NU1605 on this machine's MAUI workload (see above).dotnet test tests/KumikoUI.Core.Tests: 4,398 passed, 5 skipped, 0 failed.dotnet test tests/KumikoUI.SkiaSharp.Tests: 42 passed.dotnet test tests/KumikoUI.Maui.Tests: 452 passed.dotnet test tests/KumikoUI.Uno.Tests: 321 passed.dotnet run --project eng/DocsSnippets -c Release, thendotnet build tests/KumikoUI.Docs.Snippets.Uno -c Release: succeeded, with the new README snippets included.dotnet run --project eng/TypeNameCheck -c Release -- src/KumikoUI.Core/bin/Release/net10.0/KumikoUI.Core.dll: no public type name collides.Task.Run(...).Wait(),.Result,Wait(2000)) areasync Taskand await it (WaitAsyncwith the same 2 s limit). Core and MAUI test projects pass.