feat: replace color dropdown with clickable links in catalog sidebar
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
- Updated `side-bar.html` to use clickable links instead of a dropdown for color selection - Enhanced catalog view to generate URLs for color filters and "any color" option - Simplified the user experience for color filtering and improved accessibility
This commit is contained in:
@@ -167,6 +167,26 @@ def index(request: HttpRequest, category: str | None = None) -> HttpResponse:
|
||||
|
||||
color_item_ids = {c.id for item in items for c in item.colors.all()}
|
||||
available_colors = list(Color.objects.filter(id__in=color_item_ids))
|
||||
any_color_url = _build_catalog_url(
|
||||
selected_category.id,
|
||||
selected_subcategory.id,
|
||||
search_query=search_query,
|
||||
min_price=min_price_raw,
|
||||
max_price=max_price_raw,
|
||||
sale=filter_sale,
|
||||
new=filter_new,
|
||||
)
|
||||
for color in available_colors:
|
||||
color.catalog_url = _build_catalog_url(
|
||||
selected_category.id,
|
||||
selected_subcategory.id,
|
||||
search_query=search_query,
|
||||
min_price=min_price_raw,
|
||||
max_price=max_price_raw,
|
||||
sale=filter_sale,
|
||||
new=filter_new,
|
||||
color=str(color.id),
|
||||
)
|
||||
|
||||
if selected_color_id_raw:
|
||||
try:
|
||||
@@ -266,6 +286,7 @@ def index(request: HttpRequest, category: str | None = None) -> HttpResponse:
|
||||
'paginator': paginator,
|
||||
'pagination_query_string': pagination_query_string,
|
||||
'available_colors': available_colors,
|
||||
'any_color_url': any_color_url,
|
||||
'selected_color_id': selected_color_id_raw,
|
||||
'selected_category': selected_category,
|
||||
'selected_subcategory': selected_subcategory,
|
||||
|
||||
Reference in New Issue
Block a user