kopia lustrzana https://github.com/wagtail/wagtail
Add pagination information to page title column header
rodzic
d4eb1ec5a3
commit
53c6bf0690
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "wagtailadmin/tables/column_header.html" %}
|
||||||
|
|
||||||
|
{% block after_label %}
|
||||||
|
{% if page_obj %}
|
||||||
|
{{ page_obj.start_index }}-{{ page_obj.end_index }} of {{ page_obj.paginator.count }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -17,4 +17,5 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ column.label }}
|
{{ column.label }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% block after_label %}{% endblock %}
|
||||||
</th>
|
</th>
|
||||||
|
|
|
@ -59,6 +59,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
page_ids, [self.new_page.id, self.old_page.id, self.child_page.id]
|
page_ids, [self.new_page.id, self.old_page.id, self.child_page.id]
|
||||||
)
|
)
|
||||||
|
self.assertContains(response, "1-3 of 3")
|
||||||
|
|
||||||
def test_explore_root(self):
|
def test_explore_root(self):
|
||||||
response = self.client.get(reverse("wagtailadmin_explore_root"))
|
response = self.client.get(reverse("wagtailadmin_explore_root"))
|
||||||
|
@ -250,6 +251,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
||||||
|
|
||||||
# Check that we got the correct page
|
# Check that we got the correct page
|
||||||
self.assertEqual(response.context["page_obj"].number, 2)
|
self.assertEqual(response.context["page_obj"].number, 2)
|
||||||
|
self.assertContains(response, "51-100 of 153")
|
||||||
|
|
||||||
def test_pagination_invalid(self):
|
def test_pagination_invalid(self):
|
||||||
self.make_pages()
|
self.make_pages()
|
||||||
|
@ -412,6 +414,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
||||||
|
|
||||||
page_ids = [page.id for page in response.context["pages"]]
|
page_ids = [page.id for page in response.context["pages"]]
|
||||||
self.assertEqual(page_ids, [self.old_page.id])
|
self.assertEqual(page_ids, [self.old_page.id])
|
||||||
|
self.assertContains(response, "1-1 of 1")
|
||||||
|
|
||||||
def test_search_searches_descendants(self):
|
def test_search_searches_descendants(self):
|
||||||
response = self.client.get(reverse("wagtailadmin_explore_root"), {"q": "old"})
|
response = self.client.get(reverse("wagtailadmin_explore_root"), {"q": "old"})
|
||||||
|
|
|
@ -5,9 +5,15 @@ from wagtail.admin.ui.tables import BaseColumn, BulkActionsCheckboxColumn, Colum
|
||||||
|
|
||||||
|
|
||||||
class PageTitleColumn(BaseColumn):
|
class PageTitleColumn(BaseColumn):
|
||||||
|
header_template_name = "wagtailadmin/pages/listing/_page_title_column_header.html"
|
||||||
cell_template_name = "wagtailadmin/pages/listing/_page_title_cell.html"
|
cell_template_name = "wagtailadmin/pages/listing/_page_title_cell.html"
|
||||||
classname = "title"
|
classname = "title"
|
||||||
|
|
||||||
|
def get_header_context_data(self, parent_context):
|
||||||
|
context = super().get_header_context_data(parent_context)
|
||||||
|
context["page_obj"] = parent_context.get("page_obj")
|
||||||
|
return context
|
||||||
|
|
||||||
def get_cell_context_data(self, instance, parent_context):
|
def get_cell_context_data(self, instance, parent_context):
|
||||||
context = super().get_cell_context_data(instance, parent_context)
|
context = super().get_cell_context_data(instance, parent_context)
|
||||||
context["page_perms"] = instance.permissions_for_user(
|
context["page_perms"] = instance.permissions_for_user(
|
||||||
|
@ -132,4 +138,5 @@ class PageTable(Table):
|
||||||
context = super().get_context_data(parent_context)
|
context = super().get_context_data(parent_context)
|
||||||
context["show_locale_labels"] = self.show_locale_labels
|
context["show_locale_labels"] = self.show_locale_labels
|
||||||
context["perms"] = parent_context.get("perms")
|
context["perms"] = parent_context.get("perms")
|
||||||
|
context["page_obj"] = parent_context.get("page_obj")
|
||||||
return context
|
return context
|
||||||
|
|
Ładowanie…
Reference in New Issue