kopia lustrzana https://github.com/wagtail/wagtail
add object count to modeladmin header listing view
rodzic
5593b8b42e
commit
5f3207ca43
|
@ -16,6 +16,7 @@ Changelog
|
|||
* Removed `request.is_ajax()` usage in Documents, Image and Snippet views (Matt Westcott)
|
||||
* Simplify generic admin view templates plus ensure `page_title` and `page_subtitle` are used consistently (Matt Westcott)
|
||||
* Extend support for collapsing edit panels from just MultiFieldPanels to all kinds of panels (Fabien Le Frapper, Robbie Mackay)
|
||||
* Add object count to header within modeladmin listing view (Jonathan "Yoni" Knoll)
|
||||
* Fix: Delete button is now correct colour on snippets and modeladmin listings (Brandon Murch)
|
||||
* Fix: Ensure that StreamBlock / ListBlock-level validation errors are counted towards error counts (Matt Westcott)
|
||||
* Fix: InlinePanel add button is now keyboard navigatable (Jesse Menn)
|
||||
|
|
|
@ -532,6 +532,7 @@ Contributors
|
|||
* Stefan Hammer
|
||||
* Chakita Muttaraju
|
||||
* Fabien Le Frapper
|
||||
* Jonathan "Yoni" Knoll
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -27,6 +27,7 @@ Other features
|
|||
* Removed ``request.is_ajax()`` usage in Documents, Image and Snippet views (Matt Westcott)
|
||||
* Simplify generic admin view templates plus ensure ``page_title`` and ``page_subtitle`` are used consistently (Matt Westcott)
|
||||
* Extend support for :ref:`collapsing edit panels <collapsible>` from just MultiFieldPanels to all kinds of panels (Fabien Le Frapper, Robbie Mackay)
|
||||
* Add object count to header within modeladmin listing view (Jonathan "Yoni" Knoll)
|
||||
|
||||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -4,6 +4,23 @@
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.result-count {
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
|
||||
&:before {
|
||||
content: '(';
|
||||
}
|
||||
|
||||
&:after {
|
||||
content: ')';
|
||||
}
|
||||
|
||||
@include media-breakpoint-up(lg) {
|
||||
display: inline-block;
|
||||
margin-left: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.result-list {
|
||||
margin-bottom: 0;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{% load i18n %}
|
||||
{% block result_count %}
|
||||
<span class="result-count">{% blocktrans %}{{ result_count }} out of {{ all_count }}{% endblocktrans %}</span>
|
||||
{% endblock %}
|
|
@ -16,15 +16,20 @@
|
|||
{% block content %}
|
||||
{% block header %}
|
||||
<header class="nice-padding hasform">
|
||||
<div class="row header-title">
|
||||
<div class="left">
|
||||
<div class="col">
|
||||
{% block h1 %}<h1 {% if view.header_icon %}class="icon icon-{{ view.header_icon }}"{% endif %}>{{ view.get_page_title }}<span></span></h1>{% endblock %}
|
||||
<div class="row">
|
||||
<div class="left header-left">
|
||||
<div class="col header-title">
|
||||
{% block h1 %}
|
||||
<h1 {% if view.header_icon %}class="icon icon-{{ view.header_icon }}"{% endif %}>
|
||||
{{ view.get_page_title }}
|
||||
{% include 'modeladmin/includes/result_count.html' %}
|
||||
</h1>
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block search %}{% search_form %}{% endblock %}
|
||||
</div>
|
||||
{% block header_extra %}
|
||||
<div class="right">
|
||||
<div class="right header-right">
|
||||
{% if user_can_create %}
|
||||
<div class="actionbutton">
|
||||
{% include 'modeladmin/includes/button.html' with button=view.button_helper.add_button %}
|
||||
|
@ -46,7 +51,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content_main %}
|
||||
<div>
|
||||
<div class="main-content">
|
||||
<div class="row">
|
||||
{% block content_cols %}
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ class TestBookIndexView(TestCase, WagtailTestUtils):
|
|||
# There are four books in the test data
|
||||
self.assertEqual(response.context['result_count'], 4)
|
||||
|
||||
# The result count content is shown in the header
|
||||
self.assertContains(response, '<span class="result-count">4 out of 4</span>', html=True)
|
||||
|
||||
# User has add permission
|
||||
self.assertEqual(response.context['user_can_create'], True)
|
||||
|
||||
|
@ -101,6 +104,9 @@ class TestBookIndexView(TestCase, WagtailTestUtils):
|
|||
# JRR Tolkien has two books in the test data
|
||||
self.assertEqual(response.context['result_count'], 2)
|
||||
|
||||
# The result count content is shown in the header
|
||||
self.assertContains(response, '<span class="result-count">2 out of 4</span>', html=True)
|
||||
|
||||
for book in response.context['object_list']:
|
||||
self.assertEqual(book.author_id, 1)
|
||||
|
||||
|
@ -124,6 +130,9 @@ class TestBookIndexView(TestCase, WagtailTestUtils):
|
|||
# There are two books where the title contains 'of'
|
||||
self.assertEqual(response.context['result_count'], 2)
|
||||
|
||||
# The result count content is shown in the header
|
||||
self.assertContains(response, '<span class="result-count">2 out of 4</span>', html=True)
|
||||
|
||||
def test_search_form_present(self):
|
||||
# Test the backend search handler allows the search form to render
|
||||
response = self.get()
|
||||
|
@ -180,6 +189,9 @@ class TestAuthorIndexView(TestCase, WagtailTestUtils):
|
|||
|
||||
self.assertEqual(response.context['result_count'], 2)
|
||||
|
||||
# The result count content is shown in the header
|
||||
self.assertContains(response, '<span class="result-count">2 out of 5</span>', html=True)
|
||||
|
||||
def test_col_extra_class_names(self):
|
||||
response = self.get()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
Ładowanie…
Reference in New Issue