From 2023b24d92ba74c5a743c6668364004900c291f6 Mon Sep 17 00:00:00 2001 From: Priec Date: Thu, 25 Jun 2026 20:46:46 +0200 Subject: [PATCH] search notify where we are searching --- assets/i18n/en/main.ftl | 2 ++ assets/i18n/sk/main.ftl | 2 ++ assets/views/shop/_search.html | 23 +++++++++++++++++++++++ src/controllers/shop.rs | 7 +++++++ 4 files changed, 34 insertions(+) diff --git a/assets/i18n/en/main.ftl b/assets/i18n/en/main.ftl index a4f839f..3bbe6c3 100644 --- a/assets/i18n/en/main.ftl +++ b/assets/i18n/en/main.ftl @@ -512,6 +512,8 @@ brand-subtitle = medical supplies top-contact = Contact top-sitemap = Sitemap search-button = Search +search-scope-in = Searching in: +search-scope-all = Search the whole shop welcome = Welcome cart-units = items hotline = +421 903 410 476 diff --git a/assets/i18n/sk/main.ftl b/assets/i18n/sk/main.ftl index fb9542c..0435c1a 100644 --- a/assets/i18n/sk/main.ftl +++ b/assets/i18n/sk/main.ftl @@ -512,6 +512,8 @@ brand-subtitle = zdravotnícke potreby top-contact = Kontakt top-sitemap = Mapa stránky search-button = Hľadať +search-scope-in = Hľadáte v kategórii: +search-scope-all = Hľadať v celom obchode welcome = Vitajte cart-units = ks hotline = +421 903 410 476 diff --git a/assets/views/shop/_search.html b/assets/views/shop/_search.html index 13abed8..14477e9 100644 --- a/assets/views/shop/_search.html +++ b/assets/views/shop/_search.html @@ -47,6 +47,29 @@ + {# Scope indicator: when a category is active, make clear the search is + limited to it (not the whole shop), with a one-click escape to search + everything. Category only changes via full navigation (the sidebar), so + this stays accurate across the toolbar's results-only htmx swaps. #} + {% if selected_category and selected_category != "all" %} + {# set_global so the value survives the nested if (a plain `set` inside a + block is scoped to that block in Tera and wouldn't be visible below). #} + {% set_global _scope = selected_category_name | default(value="") %} + {% if selected_category == "none" %}{% set_global _scope = t(key="uncategorized", lang=L) %}{% endif %} + {% if _scope %} +
+ + {{ ui::icon(name="search", size="size-3.5", extra="shrink-0") }} + {{ t(key="search-scope-in", lang=L) }} {{ _scope }} + + + {{ t(key="search-scope-all", lang=L) }} + +
+ {% endif %} + {% endif %} +