Change pagination include on page search to match generic listings

pull/9948/head
Matt Westcott 2023-06-27 23:18:59 +01:00 zatwierdzone przez Matt Westcott
rodzic 71b9fb13b9
commit 38f0bda70f
2 zmienionych plików z 8 dodań i 2 usunięć
wagtail/admin
templates/wagtailadmin/pages
views/pages

Wyświetl plik

@ -34,8 +34,9 @@
{% include "wagtailadmin/pages/listing/_list_explore.html" with show_parent=1 sortable=1 sortable_by_type=0 show_bulk_actions=1 show_locale_labels=show_locale_labels %}
{% url 'wagtailadmin_pages:search' as pagination_base_url %}
{% paginate page_obj base_url=pagination_base_url %}
{% if is_paginated %}
{% include "wagtailadmin/shared/pagination_nav.html" with items=page_obj linkurl=index_url %}
{% endif %}
{% else %}
{% if query_string %}
<h2 role="alert">{% blocktrans trimmed %}Sorry, no pages match <em>{{ query_string }}</em>{% endblocktrans %}</h2>

Wyświetl plik

@ -4,6 +4,7 @@ from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.models.query import QuerySet
from django.http import Http404
from django.urls import reverse
from django.views.generic import ListView
from wagtail.admin.forms.search import SearchForm
@ -119,6 +120,9 @@ class BaseSearchView(PermissionCheckedMixin, ListView):
return pages
def get_index_url(self):
return reverse("wagtailadmin_pages:search")
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
context = super().get_context_data(**kwargs)
context.update(
@ -129,6 +133,7 @@ class BaseSearchView(PermissionCheckedMixin, ListView):
"selected_content_type": self.selected_content_type,
"ordering": self.ordering,
"show_locale_labels": self.show_locale_labels,
"index_url": self.get_index_url(),
}
)
return context