search notify where we are searching
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -47,6 +47,29 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{# 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 %}
|
||||
<div class="flex max-w-xl flex-wrap items-center gap-2 text-xs">
|
||||
<span class="inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 font-medium text-primary dark:bg-primary-dark/15 dark:text-primary-dark">
|
||||
{{ ui::icon(name="search", size="size-3.5", extra="shrink-0") }}
|
||||
{{ t(key="search-scope-in", lang=L) }} <span class="font-semibold">{{ _scope }}</span>
|
||||
</span>
|
||||
<a href="/search{% if query %}?q={{ query | urlencode }}{% endif %}"
|
||||
class="font-medium text-on-surface/60 underline-offset-2 hover:text-primary hover:underline dark:text-on-surface-dark/60 dark:hover:text-primary-dark">
|
||||
{{ t(key="search-scope-all", lang=L) }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<!-- sort + product card style switch -->
|
||||
<div class="flex flex-wrap items-center justify-end gap-3">
|
||||
<label class="flex items-center gap-2 text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70">
|
||||
|
||||
@@ -250,6 +250,13 @@ async fn run_search(
|
||||
// Numeric form so the <select> can mark the active option (Tera can't
|
||||
// compare a string param against a numeric category id).
|
||||
"selected_category_id": selected_category.parse::<i32>().unwrap_or(-1),
|
||||
// Display name of the active category, so the search bar can show that
|
||||
// the query is scoped to it. `None` for "all"/"none" (the template maps
|
||||
// "none" to the localized "uncategorized" label itself).
|
||||
"selected_category_name": selected_category
|
||||
.parse::<i32>()
|
||||
.ok()
|
||||
.and_then(|id| category_name.get(&id).cloned()),
|
||||
"uncategorized_count": uncategorized_count,
|
||||
"sort": sort,
|
||||
"per_page": per_page,
|
||||
|
||||
Reference in New Issue
Block a user