Add configurable page size selector for admin listings - #19824
Add configurable page size selector for admin listings#19824MikeAlhayek wants to merge 4 commits into
Conversation
Add an opt-in "Page size selection" option to the general site settings. When enabled with a list of allowed page sizes (e.g. 10, 25, 50, 100), admin listing pages render an "Items per page" selector next to the pager. The selected value is passed to controllers via a `pageSize` query string parameter and honored only when selection is enabled and the value is one of the configured options; any other value falls back to the configured default. - PagerOptions: add AllowPageSizeSelection, PageSizeOptions, and GetPageSize(int?) that validates the requested size. - Pager: add a constructor taking PagerParameters + PagerOptions that resolves the effective page size centrally. - Update admin listing controllers to use the new constructor. - Persist the settings through ISite/SiteSettings, the settings driver/view, the Settings recipe step, and the site settings deployment source. - Render the selector in TheAdmin Pager view, preserving the query string. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ings UX - Render the "Items per page" selector centrally in the Pager and PagerSlim shapes so it appears on both admin and front-end listings (including cursor-based PagerSlim lists such as blog posts) across all themes. When the feature is disabled (default), pagers render exactly as before. - Honor the requested page size for ListPart listings (Pager and PagerSlim) and add an optional PageSize to PagerSlimParameters. - Default PageSizeOptions to 10, 25, 50, 100. - Settings: only show the "Page size options" field when selection is enabled, and validate the input (comma-separated positive integers), always storing a sorted, de-duplicated list. - Add PagerOptions.GetPageSize(int?, int) overload for list-specific defaults. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…validate options against MaxPageSize - Extract the inline page size selector markup into a dedicated Pager_PageSizeSelector shape with default templates in TheAdmin and TheTheme, so themes can customize it like the other pager sub-shapes. This also removes the IHtmlContent-returning BuildPageSizeSelector helper that tripped analyzer error CA1859 under --warnaserror. - Reject page size options greater than the configurable MaxPageSize in the general settings validation, and surface the limit in the hint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
AFAIK, this also fixes an issue in the current implementation. |
|
Should we also make the |
|
@gvkries Agreed, this fixes that bug as well. Currently, you can simply add I'm not sure whether we should allow |
Fixes #19816
What
Adds an opt-in page size selector to admin listing pages. An administrator enables it in the general site settings and provides the list of allowed values (for example
10, 25, 50, 100). A selector then appears next to the pager on listing pages, and controllers honor the selected size when it is valid.How it works
Allow users to change the page size on listing pagescheckbox.Page size options— a comma-separated list of allowed sizes. Validation requires at least one valid size when selection is enabled; invalid/empty entries are dropped, values are de-duplicated and sorted.pageSizequery string parameter.PagerOptions.GetPageSize(int? selectedPageSize)returns the requested value only when selection is enabled and the value is one of the configured options (clamped toMaxPageSize); otherwise it falls back to the configured default. So arbitrary/unbounded page sizes are never honored.TheAdminPagerview. Each option is a link to the current URL withpageSizeset and the page number reset, preserving all other query string parameters (filters, search, etc.). The selected size is carried across pages by the existing pager links — no localStorage needed.Key changes
PagerOptions: newAllowPageSizeSelection,PageSizeOptions, andGetPageSize(int?)validation helper.Pager: newPager(PagerParameters, PagerOptions)constructor that resolves the effective page size centrally.PagerOptions(wasPagerOptions.GetPageSize()), so validation is applied uniformly. Existing overloads are unchanged and still work.ISite/SiteSettings, the settings driver + view, theSettingsrecipe step, and the site settings deployment source persist the two new values.PagerOptions.GetPageSizeand the newPagerconstructor.4.0.0.md.Notes / scope
TheAdmin), where the affected listing controllers render. Front-end pagers (PagerSlim,ListPart) keep their own page-size behavior and are out of scope.localStoragepersistence; this PR uses query-string persistence instead (simpler, shareable URLs, no client state). That can be layered on later if desired.Testing
dotnet buildof the CMS app succeeds (0 warnings/errors).PagerOptionsTests(11 cases) pass; existing admin controller tests referencingPagerOptionsstill pass.🤖 Generated with Claude Code