mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-11 02:20:59 +00:00
Merge pull request #1184 from gasman/cleanup/page-chooser-header
Clean up page chooser header
This commit is contained in:
commit
da5dfd4b26
10 changed files with 54 additions and 67 deletions
|
|
@ -28,15 +28,11 @@ class URLOrAbsolutePathField(forms.URLField):
|
|||
value = super(URLOrAbsolutePathField, self).to_python(value)
|
||||
return value
|
||||
|
||||
|
||||
class SearchForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
_placeholder = kwargs.pop('placeholder', None)
|
||||
placeholder_suffix = kwargs.pop('placeholder_suffix', "")
|
||||
placeholder = kwargs.pop('placeholder', _("Search"))
|
||||
super(SearchForm, self).__init__(*args, **kwargs)
|
||||
if _placeholder is not None:
|
||||
placeholder = _placeholder
|
||||
else:
|
||||
placeholder = 'Search {0}'.format(placeholder_suffix)
|
||||
self.fields['q'].widget.attrs = {'placeholder': placeholder}
|
||||
|
||||
q = forms.CharField(label=_("Search term"), widget=forms.TextInput())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% if page_types_restricted %}
|
||||
{% include "wagtailadmin/chooser/_page_type_restricted_warning.html" with page_type_name=page_type.get_verbose_name %}
|
||||
{% endif %}
|
||||
|
||||
<h2>{% trans "Explorer" %}</h2>
|
||||
{% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page choosing=1 %}
|
||||
|
||||
{% if pages %}
|
||||
{% include "wagtailadmin/pages/list.html" with choosing=1 allow_navigation=1 orderable=0 pages=pages parent_page=parent_page %}
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
<p class="help-block help-warning">
|
||||
{% blocktrans with type=page_type_name %}
|
||||
Only pages of type "{{ type }}" may be chosen for this field. Search results will exclude pages of other types.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{% load i18n %}
|
||||
<form class="search-bar full-width nice-padding" action="{% url 'wagtailadmin_choose_page' %}?{{ querystring }}" method="get">
|
||||
<ul class="fields">
|
||||
{% for field in search_form %}
|
||||
{% include "wagtailadmin/shared/field_as_li.html" with field=field %}
|
||||
{% endfor %}
|
||||
<li class="submit"><input type="submit" value="{% trans 'Search' %}" /></li>
|
||||
</ul>
|
||||
</form>
|
||||
|
|
@ -1,30 +1,17 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% if page_types_restricted %}
|
||||
<p class="help-block help-warning">
|
||||
{% blocktrans with type=page_type.get_verbose_name %}
|
||||
Only pages of type "{{ type }}" may be chosen for this field. Search results will exclude pages of other types.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% include "wagtailadmin/chooser/_page_type_restricted_warning.html" with page_type_name=page_type.get_verbose_name %}
|
||||
{% endif %}
|
||||
|
||||
{% if not is_searching %}
|
||||
<h2>{% trans "Explorer" %}</h2>
|
||||
{% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page choosing=1 %}
|
||||
{% else %}
|
||||
<h2>
|
||||
{% blocktrans count counter=pages|length %}
|
||||
There is one match
|
||||
{% plural %}
|
||||
There are {{ counter }} matches
|
||||
{% endblocktrans %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
<h2>
|
||||
{% blocktrans count counter=pages|length %}
|
||||
There is one match
|
||||
{% plural %}
|
||||
There are {{ counter }} matches
|
||||
{% endblocktrans %}
|
||||
</h2>
|
||||
|
||||
{% if pages %}
|
||||
{% if is_searching %}
|
||||
{% include "wagtailadmin/pages/list.html" with choosing=1 show_parent=1 pages=pages parent_page=parent_page %}
|
||||
{% else %}
|
||||
{% include "wagtailadmin/pages/list.html" with choosing=1 allow_navigation=1 orderable=0 pages=pages parent_page=parent_page %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% include "wagtailadmin/pages/list.html" with choosing=1 show_parent=1 pages=pages parent_page=parent_page %}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{% load i18n %}
|
||||
{% if page_types_restricted %}
|
||||
{% trans "Choose" as choose_str %}
|
||||
{% trans page_type.get_verbose_name as subtitle %}
|
||||
{% trans "Choose" as choose_str %}
|
||||
{% trans page_type.get_verbose_name as subtitle %}
|
||||
{% else %}
|
||||
{% trans "Choose a page" as choose_str %}
|
||||
{% trans "Choose a page" as choose_str %}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=subtitle search_url="wagtailadmin_choose_page" query_parameters="page_type="|add:page_type_string icon="doc-empty-inverse" %}
|
||||
|
|
@ -12,6 +12,6 @@
|
|||
{% include 'wagtailadmin/chooser/_link_types.html' with current='internal' %}
|
||||
|
||||
<div class="page-results">
|
||||
{% include 'wagtailadmin/chooser/_search_results.html' %}
|
||||
{% include 'wagtailadmin/chooser/_browse_results.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
{% load i18n %}
|
||||
{% trans "Choose a page" as choose_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=choose_str %}
|
||||
|
||||
<div class="nice-padding">
|
||||
{% include 'wagtailadmin/chooser/_link_types.html' with current='internal' %}
|
||||
|
||||
{% include 'wagtailadmin/chooser/_search_form.html' %}
|
||||
|
||||
<div class="page-results">{# content in here will be replaced by live search results #}
|
||||
{% include 'wagtailadmin/chooser/_search_results.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
function(modal) {
|
||||
$('.link-types a', modal.body).click(function() {
|
||||
modal.loadUrl(this.href);
|
||||
return false;
|
||||
});
|
||||
|
||||
{% include 'wagtailadmin/chooser/_search_behaviour.js' %}
|
||||
ajaxifySearchResults();
|
||||
}
|
||||
|
|
@ -1,4 +1,22 @@
|
|||
{% load i18n wagtailadmin_tags %}
|
||||
{% comment %}
|
||||
|
||||
Variables accepted by this template:
|
||||
|
||||
title
|
||||
subtitle
|
||||
|
||||
search_url - if present, display a search box. This is a URL route name (taking no parameters) to be used as the action for that search box
|
||||
query_parameters - a query string (without the '?') to be placed after the search URL
|
||||
|
||||
icon - name of an icon to place against the title
|
||||
|
||||
tabbed - if true, add the classname 'tab-merged'
|
||||
merged - if true, add the classname 'merged'
|
||||
|
||||
add_link - if present, display an 'add' button. This is a URL route name (taking no parameters) to be used as the link URL for the button
|
||||
add_text - text for the 'add' button
|
||||
{% endcomment %}
|
||||
<header class="nice-padding {% if merged %}merged{% endif %} {% if tabbed %}tab-merged{% endif %} {% if search_form %}hasform{% endif %}">
|
||||
<div class="row">
|
||||
<div class="left">
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def browse(request, parent_page_id=None):
|
|||
|
||||
shown_pages = []
|
||||
for page in pages:
|
||||
page.can_choose = issubclass(page.specific_class, desired_class)
|
||||
page.can_choose = issubclass(page.specific_class or Page, desired_class)
|
||||
page.can_descend = page.get_children_count()
|
||||
|
||||
if page.can_choose or page.can_descend:
|
||||
|
|
@ -66,7 +66,6 @@ def browse(request, parent_page_id=None):
|
|||
'querystring': get_querystring(request),
|
||||
'searchform': search_form,
|
||||
'pages': shown_pages,
|
||||
'is_searching': is_searching,
|
||||
'page_type_string': page_type,
|
||||
'page_type': desired_class,
|
||||
'page_types_restricted': page_types_restricted
|
||||
|
|
@ -79,7 +78,6 @@ def browse(request, parent_page_id=None):
|
|||
'parent_page': parent_page,
|
||||
'pages': shown_pages,
|
||||
'search_form': search_form,
|
||||
'is_searching': False,
|
||||
'page_type_string': page_type,
|
||||
'page_type': desired_class,
|
||||
'page_types_restricted': page_types_restricted
|
||||
|
|
|
|||
Loading…
Reference in a new issue