mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-28 00:17:06 +01:00
Improve behaviour when filtering returns no results
This commit is contained in:
parent
4e59266743
commit
95b55af8e7
@ -2,29 +2,39 @@
|
||||
{% load wagtailadmin_tags i18n %}
|
||||
|
||||
{% block after_label %}
|
||||
{% if page_obj %}
|
||||
{% with start_index=page_obj.start_index end_index=page_obj.end_index result_count=page_obj.paginator.count %}
|
||||
{% if is_searching or is_filtering %}
|
||||
{% if is_searching_whole_tree %}
|
||||
{% with start_index=page_obj.start_index end_index=page_obj.end_index result_count=page_obj.paginator.count %}
|
||||
{% if is_searching or is_filtering %}
|
||||
{% if is_searching_whole_tree %}
|
||||
{% if result_count %}
|
||||
{% blocktranslate trimmed %}
|
||||
{{ start_index }}-{{ end_index }} of {{ result_count }} across entire site.
|
||||
{% endblocktranslate %}
|
||||
<a href="{{ table.base_url }}{% querystring p=None search_all=None %}">
|
||||
{% blocktranslate trimmed with title=parent_page.get_admin_display_title %}Search within '{{ title }}'{% endblocktranslate %}
|
||||
</a>
|
||||
{% else %}
|
||||
{% blocktranslate trimmed %}
|
||||
No results across entire site.
|
||||
{% endblocktranslate %}
|
||||
{% endif %}
|
||||
<a href="{{ table.base_url }}{% querystring p=None search_all=None %}">
|
||||
{% blocktranslate trimmed with title=parent_page.get_admin_display_title %}Search within '{{ title }}'{% endblocktranslate %}
|
||||
</a>
|
||||
{% else %}
|
||||
{% if result_count %}
|
||||
{% blocktranslate trimmed with title=parent_page.get_admin_display_title %}
|
||||
{{ start_index }}-{{ end_index }} of {{ result_count }} within '{{ title }}'.
|
||||
{% endblocktranslate %}
|
||||
<a href="{{ table.base_url }}{% querystring p=None search_all=1 %}">
|
||||
{% translate "Search the whole site" %}
|
||||
</a>
|
||||
{% else %}
|
||||
{% blocktranslate trimmed with title=parent_page.get_admin_display_title %}
|
||||
No results within '{{ title }}'.
|
||||
{% endblocktranslate %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% blocktranslate trimmed %}
|
||||
{{ start_index }}-{{ end_index }} of {{ result_count }}
|
||||
{% endblocktranslate %}
|
||||
<a href="{{ table.base_url }}{% querystring p=None search_all=1 %}">
|
||||
{% translate "Search the whole site" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% blocktranslate trimmed %}
|
||||
{{ start_index }}-{{ end_index }} of {{ result_count }}
|
||||
{% endblocktranslate %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
@ -127,7 +127,6 @@ class BaseIndexView(GenericIndexView):
|
||||
# Search
|
||||
self.query_string = None
|
||||
self.is_searching = False
|
||||
self.is_searching_whole_tree = False
|
||||
if "q" in self.request.GET:
|
||||
self.search_form = SearchForm(
|
||||
self.request.GET, placeholder=_("Search pages…")
|
||||
@ -139,7 +138,10 @@ class BaseIndexView(GenericIndexView):
|
||||
|
||||
if self.query_string:
|
||||
self.is_searching = True
|
||||
self.is_searching_whole_tree = bool(self.request.GET.get("search_all"))
|
||||
|
||||
self.is_searching_whole_tree = bool(self.request.GET.get("search_all")) and (
|
||||
self.is_searching or self.is_filtering
|
||||
)
|
||||
|
||||
return super().get(request)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user