{% load i18n %}
{% load lfs_tags %}
<div class="filtered-navigation-portlet portlet">

    <div class="portlet-header">
        {% trans 'Filter' %} <a href="{% url lfs_reset_all_product_filter category.slug %}">[x]</a>
    </div>
    
    <div class="portlet-body">    
        {% for property_group in product_filters %}
            {% if property_group.items %}
                <div class="portlet-item">
                    <div class="filter-title {% if forloop.first %}first{% endif %}">
                        <span>
                            {{ property_group.name }}
                        </span>
                        {% if property_group.show_reset %}
                            <a href="{% url lfs_reset_product_filter category.slug property_group.id %}">[x]</a>
                        {% endif %}                    
                    </div>
                    {% for property in property_group.items %}
                        <div>
                            {% if property_group.object.is_number_field %}
                                {% if property_group.show_quantity %}
                                    <a href='{% url lfs_set_product_filter category.slug property_group.id property.min property.max %}'>
                                        {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }} ({{ property.quantity }})
                                    </a>
                                {% else %}
                                    <span>
                                        {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }}
                                    </span>
                                {% endif %}
                            {% else %}
                                {% if property.show_quantity %}
                                    <a href='{% url lfs_set_product_filter category.slug property_group.id property.value %}'>
                                        {{ property.title }} {{ property_group.unit|safe }} ({{ property.quantity }})
                                    </a>
                                {% else %}
                                    <span>
                                        {{ property.title }} {{ property_group.unit|safe }}
                                    </span>
                                {% endif %}
                        
                            {% endif %}
                        </div>        
                    {% endfor %}
                </div>    
            {% endif %}        
        {% endfor %}

        <div class="portlet-item">
            
            <div class="filter-title">
                <span>{% trans 'Price' %}</span>
                {% if price_filters.show_reset %}
                    <a href="{% url lfs_reset_price_filter category.slug %}">[x]</a>
                {% endif %}            
            </div>
            
            {% for price_filter in price_filters.items %}
                <div>
                    {% if price_filters.show_quantity %}
                        <a href="{% url lfs_set_price_filter category.slug %}?min={{ price_filter.min }}&amp;max={{ price_filter.max }}">
                            {% trans 'Up to' %} {{ price_filter.max|number }}
                            ({{ price_filter.quantity }})
                        </a>
                    {% else %}
                        <span>
                            {% trans 'Up to' %} {{ price_filter.max|currency }}
                        </span>                            
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
        
    <div class="portlet-footer">
        <a href="{% url lfs_reset_all_product_filter category.slug %}">
            {% trans 'Reset all filters' %}
        </a>
    </div>        
</div>    
