Repository navigation
listing block - #107
listing block#107nileshgulia1 wants to merge 67 commits into
Conversation
Thanks for the fix @sneridagh . I did a few more fixes in the latest commits. Now the type field looks fine, along with other metadata fields(sort_on, limit, b_size) that are supplied along with the main query. |
# Conflicts: # packages/blocks/Listing/ListingBlockView.tsx # pnpm-lock.yaml
The listing block view fetched its own results from the CMS UI's @querystringSearch route, so published pages rendered "No results" on the server and showed items only after the client fetched them. The server loader only looked for top-level listing blocks, and listings now live inside the block editor's value. - The server fills in the items of listing blocks at any depth, searches in the page so it isn't in its own listing, and empties a listing whose query fails instead of failing the page. It leaves the CMS UI views alone, so the edit form doesn't save the items. - The view renders the items it gets, like the other blocks. - The edit component previews the query with the `querystringResults` utility, which the CMS UI registers, so @plone/blocks no longer depends on react-router, usehooks-ts or CMS UI paths. The preview searches in the edited page too. - @plone/client accepts the numbers and the boolean sort order that blocks store, and searches in a content object with `path`.
📖 16 files modified
Preview · build overview · plone-registry · built Dec. 2, 2026, 7:32 a.m. UTC |
The listing block's preview sends its whole querystring value: the criteria and the search options. The route keeps the well-formed criteria and the known options, so callers can't set others like `fullobjects`, and searches with POST, as before. It no longer decodes the parameter twice, which broke values with `%`. The acceptance tests from #267 send the querystring value, as its notes anticipated, and check that the options apply.
# Conflicts: # packages/aurora/src/app/config/server.server.ts # packages/cmsui/routes/querystringSearch.tsx
- Criterion values follow their operator: "Matches any of" takes several values with a multi-select and stores them as a list, as Volto does. The single select showed only one value of a list saved by Volto and replaced the list on any change. A value saved as a string still shows. - @plone/client applies the `depth` of path criteria as `path::depth`, as Volto does, so the server and the editor preview list the same content as Volto. The route and the preview pass it on. - The listing view links its items with the app's `Link`, and renders no links in the editor, like the teaser block, so a click doesn't leave the edit form.
The stories' indexes had made-up operators, like `is` with a single `SelectionWidget` for Type, so they never showed the "Matches any of" multi-select that Plone sites get. They now use the operations, titles and widgets of Plone 6's `@querystring`, with `sortable_title` for sorting, and a new story shows a query saved by Volto, whose values are lists.
The placeholder shrank to the width of its text, because the block container's `justify-items: start` applies to block layout in current browsers.
|
@sneridagh This is ready for another review. Would be great if you can look at this during the sprint. Thank you. |
The listing showed the first 25 results only, the default batch of Plone, without a way to see the others. - The server loads the page in the URL, with the "Paginate every" of the block, or the new `defaultPageSize` setting (25, as in Volto). The page is in `page`, or `page_<block id>` when the page has several listings, the same parameters as Volto, so links keep working. It only loads the region the page renders. - The view links to the other pages under the items, with contract classnames, keeping the other parameters and scrolling to the listing. They're links, so they work without JavaScript, and the server renders each page. The editor previews the first page, without links. - The blocks migrated from Volto keep their id, which the page parameter uses.
The chevrons of @plone/icons, inline, since the Icon component adds classes outside the content's classname contract. They keep "Previous page" and "Next page" as their accessible names.
The loader of the listing blocks' results was in the app configuration of @plone/aurora, which then had to import the listing's pagination helpers from @plone/blocks. It's listing logic, so it now lives with the block: @plone/blocks registers it as a `rootContentSubRequest` utility in its `config/server.ts`, which the registry loads on the server like @plone/cmsui's. The app configuration is back to main's, without the loader. The loader is unchanged. It types the arguments it uses with @plone/types, as packages can't import from @plone/aurora, and @plone/blocks depends on @plone/plate for the `main` region's key.
Resolves the conflicts with #539, which fixed listing blocks saved by Volto on main. The listing loader of this branch, in `@plone/blocks`, replaces the one #539 added to `@plone/aurora`. From #539 it keeps the `metadata_fields` option of `querystringSearch`, the image guard of the summary variation and the acceptance test for pages saved by Volto, and `loadListings` now reads the query of blocks saved before Volto had block schemas. Assisted-by: Claude Opus 5.5
# Conflicts: # packages/blocks/package.json
Cloned from Original branch on seven: plone/volto#8252
Listing block: edit, live preview, server rendering, pagination
Adds the editing side of the Listing block and makes its results work.
@plone/blocksListing/index.tsx,Listing/schema.tsx: register the edit component, the schema (headline and thequerystringwidget), the icon and the default block width.Listing/ListingBlockEdit.tsx:querystringResultsutility that@plone/cmsuiregisters. Like the teaser getting its object browser withconfig.getWidget, the block doesn't fetch data or depend onreact-routeror@plone/cmsui(packages/blocks/AGENTS.md).Listing/ListingBlockView.tsx: renders only the items it's given; it never fetches.Link, so they navigate within the app. In the editor they're plain text, so a click doesn't leave the edit form.#listing-<id>anchor. In the editor the page numbers aren't links.block-listing__pagination,block-listing__page…). The arrows are inline SVGs because theIconcomponent adds classes outside the contract.Listing/pagination.ts: helpers shared by the view and the loader:settings.defaultPageSize, else 25;page, orpage_<block id>when the page has several listings;Listing/loadListings.ts,config/server.ts: the server-side loading of the results, registered as arootContentSubRequestutility in the blocks' server configuration (loaded by the registry, like@plone/cmsui/config/server.ts). It replaces the loader onmainin@plone/aurora'sserver.server.ts, which only handled top-level listings. It:mainregion, or at the top level of content saved before Aurora;@@edit, …), whose forms share this content and would otherwise save the results.index.ts: setsconfig.settings.defaultPageSize ??= 25(Volto's default) for listings without "Paginate every". Before this, listings silently stopped at Plone's default batch of 25 items.styles/content.css: the layout of the page navigation.locales/*/common.json: labels for the navigation (en, de, it).package.json: depends on@plone/plate, for themainregion's key. It already did so through@plone/layout, so there's no cycle.Listing/*.test.ts(x)andconfig/server.test.tsare new or extended.index.test.tsanddocs.test.tsonly addsettings: {}to their fake configs, because the install now setsdefaultPageSize.@plone/cmsuicomponents/QuerystringWidget/QuerystringWidget.tsx,QuerystringWidgetContext.tsx:MultipleSelectionWidget) use Quanta'sMultiSelectand store a list, as Volto does. Before, a single select showed one value of a list saved by Volto and replaced the whole list on any change.components/QuerystringWidget/useQuerystringResults.ts,config/widgets.ts: the preview hook, registered as thedefaultquerystringResultsutility. It searches in the edited page, so the preview matches the published page, and passesdepthand the search options.routes/querystringSearch.tsx: (the route itself was registered on main in Register the @querystringSearch route #267)fullobjects;%.components/QuerystringWidget/QuerystringWidget.stories.tsx: the stories use the operators and widgets of Plone 6's@querystring, which they didn't before. A new "Saved by Volto" story shows list values.QuerystringWidget.test.tsxis new.acceptance/tests/querystring-search.test.ts(Register the @querystringSearch route #267's) sends the whole querystring value, as its notes anticipated, and checks that the search options apply.acceptance/tests/listing-block.test.tscovers:@plone/clientvalidation/querystring-search.ts,restapi/querystring-search/get.ts:sort_orderthat blocks and Volto store;path, to search in a content object;depthto path criteria aspath::depth, as Volto does, so a depth set in Volto lists the same content in Aurora.querystring-search.test.ts.@plone/auroraapp/config/server.server.ts: the listing loader moved to@plone/blocks, so this file only loses it.app/config/server/migrations.server.ts: when content saved by Volto is converted for the editor, each Plone block keeps its id. This keeps Volto's per-listing page key (page_<block id>) working, and keeps the ids stable after the first save in Aurora. Before, converted blocks had no id. The test (content-migrations.server.test.ts) is updated.@plone/types(.d.ts, types only)services/querystring-search.d.ts:QuerystringParameteraccepts what blocks store: numbers, a booleansort_order,depth.config/Utilities.d.ts:QuerystringResultsUtility, so thequerystringResultsutility is typed.blocks/index.d.ts:ListingBlockFormData.paginationandListingPagination.Other
news/*: changelog entries for blocks, cmsui, client, aurora and types.pnpm-lock.yaml:@plone/plateas a dependency of@plone/blocks.📚 Documentation preview 📚: https://plone-aurora--107.org.readthedocs.build/