Skip to content
Snippets Groups Projects
Commit 7361a194 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Started fixing facets (added search_facets)

parent 7447d0c2
No related branches found
No related tags found
1 merge request!50Upgraded to CKAN 2.10
......@@ -291,14 +291,14 @@ def odsh_show_testbanner():
return config.get('ckanext.odsh.showtestbanner', False) == True
def odsh_get_facet_items_dict(name, limit=None):
def odsh_get_facet_items_dict(name, search_facets, limit=None):
'''
Gets all facets like 'get_facet_items_dict' but sorted alphabetically
instead by count.
'''
if name == 'groups':
limit = 20
facets = helpers.get_facet_items_dict(name, None, limit)
facets = helpers.get_facet_items_dict(name, search_facets, limit)
facets.sort(key=lambda it: (it['display_name'].lower(), -it['count']))
return facets
......
......@@ -7,7 +7,7 @@
{% endblock styles %}
{% block breadcrumb_content %}
<li class="active">{{ h.nav_link(_('Datasets'), named_route='dataset.search', highlight_actions = 'new index') }}</li>
<li class="active">{{ h.nav_link(_('Datasets'), named_route='dataset.search') }}</li>
{% endblock %}
{% block toolbar %}
......@@ -58,7 +58,7 @@ method="get" data-module="select-switch">
<div class="filters">
<div>
{% for facet in c.facet_titles %}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet) }}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet, search_facets=search_facets) }}
{% endfor %}
</div>
......
......@@ -6,8 +6,8 @@
{% endblock %}
{% block facet_list_items %}
{# {% with items = items or h.get_facet_items_dict(name,20) %} #}
{% with items = items or h.odsh_get_facet_items_dict(name)|selectattr('count')|list %}
{# {% with items = items or h.get_facet_items_dict(name, search_facets, 20) %} #}
{% with items = items or h.odsh_get_facet_items_dict(name, search_facets)|selectattr('count')|list %}
{% if items %}
<nav>
{% set title = title or h.get_facet_title(name) %}
......@@ -22,7 +22,7 @@
{% set label = _(label)%}
{% endif%}
{% set count = count_label(item['count']) if count_label else ('%d' % item['count']) %}
{% set label_truncated = h.truncate(label, 25) if not label_function else label %}
{% set label_truncated = label|truncate(25) if not label_function else label %}
<li class="{{ nav_item_class or 'nav-item' }}">
<div class="facet_label">
{# TODO: checkbox-id vereinheitlichen (code-duplikation) und sicher gegen Titel mit Leerzeichen machen! #}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment