I'm using Search API with Facets and a view to display the results. Everything works as expected but I would like to have a reset button per facet, that could be used as a "Show all" button.
For the moment I'm using facets_preprocess_facets_item_list(&$variables)
to create an extra item on the top of every list, eg.
- Facet 1 : Region
All regions, Region 1, Region 2, ... - Facet 2 : Financial support
All financial supports, Financial support 1, Financial support 2, ... - Facet 3 : Status
All statuses, Status 1, Status 2, ... - Facet 4 : Sector
All sectors, Sector 1, Sector 2, ...
To construct the "All ..." links, I'm getting the parameters of the current page and I clean up the filters. For example if the user clicks on the "All financial supports" [facet 2] link while the current page parameters are
../organizations?[facet 1]organizations%5B0%5D=region%3A18&[facet 2]organizations%5B1%5D=financial_support%3A1&[facet 3]organizations%5B2%5D=status%3A10&[facet 4]organizations%5B3%5D=sector%3A28
the parameters become
../organizations?[facet 1]organizations%5B0%5D=region%3A18&[facet 2][facet 3]organizations%5B2%5D=status%3A10&[facet 4]organizations%5B3%5D=sector%3A28
It works, but I'm not conviced that this is the best solution because I've managed to dramaticaly slow down the display of the view and, well... it's not very elegant.
Do you know if there is another, more Drupalish solution to implement a reset button per facet?
Thank you in advance for your help.