feat(categories): Sortowanie podkategorii malejąco po liczbie firm
Podkategorie są teraz sortowane od największej do najmniejszej liczby przypisanych firm (od lewej do prawej). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
75c6b9ca68
commit
23726f3c10
@ -953,13 +953,18 @@
|
||||
<!-- Row 2: Subcategories (hidden by default, shown when main category selected) -->
|
||||
{% for main_cat in main_categories %}
|
||||
<div class="category-filter-sub" id="subcats-{{ main_cat.slug }}" data-parent="{{ main_cat.slug }}">
|
||||
{# Zbierz podkategorie z licznikami i posortuj malejąco #}
|
||||
{% set sub_counts = [] %}
|
||||
{% for sub in main_cat.subcategories %}
|
||||
{% set count = companies|selectattr('category_id', 'equalto', sub.id)|list|length %}
|
||||
{% if count > 0 %}
|
||||
<button class="category-badge category-sub" onclick="filterSubCategory('{{ sub.slug }}', '{{ main_cat.slug }}')" data-parent="{{ main_cat.slug }}">
|
||||
{{ sub.name }} ({{ count }})
|
||||
{% set count = companies|selectattr('category_id', 'equalto', sub.id)|list|length %}
|
||||
{% if count > 0 %}
|
||||
{% set _ = sub_counts.append({'sub': sub, 'count': count}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for item in sub_counts|sort(attribute='count', reverse=true) %}
|
||||
<button class="category-badge category-sub" onclick="filterSubCategory('{{ item.sub.slug }}', '{{ main_cat.slug }}')" data-parent="{{ main_cat.slug }}">
|
||||
{{ item.sub.name }} ({{ item.count }})
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user