From 2242244c4b8a917c591aff15813c73705a136232 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 26 Aug 2015 15:57:03 +0100 Subject: [PATCH 1/2] Show total count of found snippets on snippet listing as well --- .../templates/wagtailsnippets/snippets/results.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtail/wagtailsnippets/templates/wagtailsnippets/snippets/results.html b/wagtail/wagtailsnippets/templates/wagtailsnippets/snippets/results.html index 09edc8b12..3bb5ec29f 100644 --- a/wagtail/wagtailsnippets/templates/wagtailsnippets/snippets/results.html +++ b/wagtail/wagtailsnippets/templates/wagtailsnippets/snippets/results.html @@ -2,7 +2,7 @@ {% if items %} {% if is_searching %}

- {% blocktrans count counter=items|length %} + {% blocktrans count counter=items.paginator.count %} There is one match {% plural %} There are {{ counter }} matches From 94565bac8adcfc9f8dd0e0dcce62ebc97a2cfc47 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 26 Aug 2015 16:38:12 +0100 Subject: [PATCH 2/2] Fixed snippet chooser pagination for non searchable snippets Pagination links are generated from the search form action. This change always puts the search form into the HTML, but removes the search box and submit button when the snippet is not searchable. The user doesn't see the form and the pagination links work again. --- .../templates/wagtailsnippets/chooser/choose.html | 10 ++++++---- .../templates/wagtailsnippets/chooser/choose.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.html b/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.html index b5b6ea84b..1d7bf82e5 100644 --- a/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.html +++ b/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.html @@ -3,16 +3,18 @@ {% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=snippet_type_name icon="snippet" %}
- {% if is_searchable %} - - {% endif %} + {% endif %} +
{% include "wagtailsnippets/chooser/results.html" with choosing=1 %} diff --git a/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.js b/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.js index d2320259b..fe5cd2a18 100644 --- a/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.js +++ b/wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/choose.js @@ -30,7 +30,7 @@ function initModal(modal) { function setPage(page) { var dataObj = {p: page, results: 'true'}; - if ($('#id_q').val().length) { + if ($('#id_q').length && $('#id_q').val().length) { dataObj.q = $('#id_q').val(); }