Обновили шапку и вывод всехтоваров. Добавили фильтры
This commit is contained in:
65
myproject/templates/components/category_filter_buttons.html
Normal file
65
myproject/templates/components/category_filter_buttons.html
Normal file
@@ -0,0 +1,65 @@
|
||||
{% comment %}
|
||||
Компонент кнопок быстрого фильтра по категориям и типам продуктов
|
||||
|
||||
Параметры:
|
||||
- categories: queryset категорий для отображения
|
||||
- current_category: ID текущей выбранной категории (опционально)
|
||||
- show_type_filters: показывать ли фильтры типов (по умолчанию True)
|
||||
{% endcomment %}
|
||||
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title mb-3">
|
||||
<i class="bi bi-filter"></i> Быстрые фильтры
|
||||
</h6>
|
||||
|
||||
<!-- Фильтры по типу товара -->
|
||||
{% if show_type_filters|default:True %}
|
||||
<div class="mb-3">
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Фильтр по типу">
|
||||
<a href="{% url 'products:all-products' %}"
|
||||
class="btn {% if request.resolver_match.url_name == 'all-products' %}btn-primary{% else %}btn-outline-primary{% endif %}">
|
||||
<i class="bi bi-grid"></i> Все товары
|
||||
</a>
|
||||
<a href="{% url 'products:product-list' %}"
|
||||
class="btn {% if request.resolver_match.url_name == 'product-list' %}btn-success{% else %}btn-outline-success{% endif %}">
|
||||
<i class="bi bi-box"></i> Только поштучно
|
||||
</a>
|
||||
<a href="{% url 'products:productkit-list' %}"
|
||||
class="btn {% if request.resolver_match.url_name == 'productkit-list' %}btn-info{% else %}btn-outline-info{% endif %}">
|
||||
<i class="bi bi-box-seam"></i> Только комплекты
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Фильтры по категориям -->
|
||||
{% if categories %}
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-2">
|
||||
<i class="bi bi-tags"></i> Категории:
|
||||
</label>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<!-- Кнопка "Все категории" -->
|
||||
<a href="?{% if request.GET.search %}search={{ request.GET.search }}&{% endif %}{% if request.GET.is_active %}is_active={{ request.GET.is_active }}{% endif %}"
|
||||
class="btn btn-sm {% if not current_category %}btn-secondary{% else %}btn-outline-secondary{% endif %}">
|
||||
Все
|
||||
</a>
|
||||
|
||||
<!-- Кнопки категорий -->
|
||||
{% for category in categories %}
|
||||
<a href="?category={{ category.id }}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.is_active %}&is_active={{ request.GET.is_active }}{% endif %}"
|
||||
class="btn btn-sm {% if current_category == category.id|stringformat:'s' %}btn-secondary{% else %}btn-outline-secondary{% endif %}">
|
||||
{{ category.name }}
|
||||
{% if category.product_set.count or category.productkit_set.count %}
|
||||
<span class="badge bg-light text-dark">
|
||||
{{ category.product_set.count|add:category.productkit_set.count }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user