{% extends "oscar/catalogue/browse.html" %}

{% load i18n %}
{% load category_tags %}
{% load ocyanjson ocyan_oscar ocyan_main %}

{% block extrahead %}
{{ block.super }}

{% block canonical %}
<link rel="canonical" href="{% absolute_url request.path %}" />
{% endblock %}
{% endblock %}

{% block column_left %}
    {% block prepend_column_left %}{% endblock %}

    {% block categories %}
    {% ocyanjson "theme" "category_navigation_depth" 1 as category_navigation_depth %}
    {% category_tree as tree_categories %}
    {% if tree_categories %}
        <h4>{% trans "Show results for" %}</h4>
        <div class="side_categories">
            <ul class="nav nav-list">
                {% for tree_category, info in tree_categories %}
                {% if info.level < category_navigation_depth or tree_category|is_selected:category %}
                    <li class="nav-item {% if tree_category.pk == category.pk %}active{% endif %}">
                        <a class="nav-link text-dark" href="{{ tree_category.get_absolute_url }}">
                            {% if tree_category.pk == category.pk %}
                                <strong>{{ tree_category.name }}</strong>
                            {% else %}
                                {{ tree_category.name }}    
                            {% endif %}
                        </a>
                    {% endif %}
                    {% if info.has_children %}<ul class="nav flex-column sub-nav">{% else %}</li>{% endif %}
                    {% for n in info.num_to_close %}
                        </ul></li>
                    {% endfor %}
                {% endfor %}
            </ul>
        </div>
    {% endif %}
    {% endblock %}

    {% block facets %}
    {% if has_facets %}
        <h4>{% trans "Refine by" %}</h4>
        <div class="side_categories">
            {% for field, data in facet_data.items %}
                {% if data.results %}
                    {% include 'search/partials/facet.html' with name=data.name items=data.results %}
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
    {% endblock %}

    {% block append_column_left %}{% endblock %}
{% endblock %}

{% block content %}
    {% block category_blocks %}
        {% ocyanjson "oscar" "show_child_category_blocks" False as show_child_category_blocks %}
        {% if show_child_category_blocks and category.depth < 2 and category.has_children %}
            {% include 'oscar/catalogue/partials/category_blocks.html' %}
        {% endif %}
    {% endblock %}
    
    {{block.super}}
{% endblock %}
