[PP-1] Allow the ProjectBrowser render element to customize the available sort options

Created on 5 March 2025, about 1 month ago

Problem/Motivation

This is postponed on Allow the frontend code to be initialized with a preconfigured query Active .

In that issue, we started to add some degree of display customizability to project browsers -- really, it's more about enabling or disabling certain parts of the "chrome" (i.e., filters, sorts, pagination, etc.)

At the moment, there is no way to disable certain filters from showing up. All of the filters defined by the source will appear. For mini-browsers, this might not be desirable.

Proposed resolution

Add a #filters property to the ProjectBrowser render element. If provided, it is an associative array whose keys are the machine names of the filters, and whose values are the default values for those filters. Every key must match the name of a filter defined by the source's getFilterDefinitions() method.

Example (assuming the source is

drupalorg_jsonapi<code>):

<code>
$element['#filters'] = [
  'development_status' => TRUE,
  'categories' => [123, 456],   // The taxonomy IDs for the categories to choose
];

This will suppress the display of all filters except these two, and it will adjust the default values of these two filters from whatever the source originally set.

ProjectBrowserBlock should also add this to its configuration form, in a limited way. It won't be able to set the default values (yet), but it will be able to enable or disable the filters. The filters will be presented as a set of checkboxes, keyed by internal name, labeled by human-readable name. All will be selected by default. The final selection is stored in block settings as an array of filter names (['development_status', 'categories', ...]), and applied to the render element during the build() method to show or hide certain filters.

Feature request
Status

Postponed

Version

2.0

Component

Code

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024