Open aleeexgreeen opened 1 week ago
As @amercader suggested it might be easier to modify get_facet_items_dict
to return the information you need than to do it in jinja2.
@wardi Okay thanks, it was easier than I thought! I just want to confirm that by default the accordions should be expanded and there should add a config option to have the collapsed by default, or does there need to be more discussions about that?
Hello! By request of the designers of the UI revamp, they would like the facets to appear as accordions. They have requested by default if there are no active options within a facet, it should be collapsed, otherwise it should be expanded.
Screenshots for context: Default, facets with no active item
Default, facets with 1 or more active items
I have a working version of this, that is probably not efficient and uses jinja filters right now. I'm using
{% set active_items = items|selectattr('active')|list|length >= 1 %}
to see if there are any active items within a facet and ifactive_items
is empty, I'm collapsing that facet accordion. For full code, see facet_list.htmlCKAN currently can indicate whether an item in a facet is active (
item.active
-> happening in{% for item in items %}
), but ultimately, I need to indicate whether there are any active items in the facet before the for loop to collapse and expand the accordions accordingly (🤣 ) and I'm wondering what is the best way to do so?