Info |
---|
Valid from Datafari 6.32 (DatafariUI v2) |
The search information block consists in the information traditionally shown above the search results. It provides several insights about the current search such as the terms of the search, the number of results and the filters currently in use. It is shown with a red bar on the side below:
...
👉 You can modify this example to add other filters using the matching found or not to go to another format function you added. The most important is to locate where to inject your new code. For Query Facet it is in renderQueryFacetSection
and for Field Facet and HierarchicalFacet it is in renderFieldFacetSection
...
Info |
---|
Valid from Datafari 5.2 to 6. |
...
1 (DatafariUI v1) |
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The search information block consists in the information traditionally shown above the search results. It provides several insights about the current search such as the terms of the search, the number of results and the filters currently in use. It is shown with a red bar on the side below: Filters displayed from field facet or query facet can’t be personalized, however, other filters can. For example, the custom date range that is part of the creation date facet has a customized rendering. This documentation will explain how it is done, and how the system can be used for other custom filters in the future. There are different part in the management of a filter:
We will not be interested in the deletion of the filter. However, the creation and rendering are the part we will work on. The documentation is based on the study of the custom date range available in DatafariUI. Creating the filterFor our study case, the filter is created in the I won’t go into details on how the whole component works, and instead focus on the interesting parts for our problem. When the user clicks on the “Go” button, a new filter is created. This is done by dispatching a REGISTER_FILTER event to the query context:
If you have a look at the newFilter object, this is what defines our filter. You can see it has two keys:
Rendering the filterDefining how the filter should be rendered takes place in the useFilterFormater hook (https://gitlab.datafari.com/datafari-community/DatafariUI/-/blob/master/src/Hooks/useFilterFormater.js). There is a filterFormat function in there that you need to change to add support for your new type of filter.
As you can see, there is a switch on the filter.extra.type key of the filter object. You can add a case statement for your new type of filter and add a dedicated rendering management based on the elements you put into the extra object. That is what has been done for the rendering of the date range example above. |