Adds a new HelpPanel (#4374)

pull/4379/merge
Kevin Chung 2018-03-15 08:46:34 -07:00 zatwierdzone przez Bertrand Bordage
rodzic a46ba4805b
commit d188576af8
4 zmienionych plików z 52 dodań i 0 usunięć

Wyświetl plik

@ -281,6 +281,7 @@ Contributors
* Todd Dembrey
* Sebastian Brestin
* Casper Timmers
* Kevin Chung
Translators
===========

Wyświetl plik

@ -243,6 +243,30 @@ SnippetChooserPanel
See :ref:`snippets` for more information.
HelpPanel
---------
.. module:: wagtail.admin.edit_handlers
.. class:: HelpPanel(content='', template='wagtailadmin/edit_handlers/help_panel.html', heading='', classname='')
.. attribute:: HelpPanel.content
HTML string that gets displayed in the panel.
.. attribute:: HelpPanel.template
Path to a template rendering the full panel HTML.
.. attribute:: HelpPanel.heading
A heading for the help content.
.. attribute:: HelpPanel.classname
String of CSS classes given to the panel which are used in formatting and scripted interactivity.
Built-in Fields and Choosers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wyświetl plik

@ -387,6 +387,27 @@ class MultiFieldPanel(BaseCompositeEditHandler):
return classes
class HelpPanel(EditHandler):
def __init__(self, content='', template='wagtailadmin/edit_handlers/help_panel.html',
heading='', classname=''):
super().__init__(heading=heading, classname=classname)
self.content = content
self.template = template
def clone(self):
return self.__class__(
content=self.content,
template=self.template,
heading=self.heading,
classname=self.classname,
)
def render(self):
return mark_safe(render_to_string(self.template, {
'self': self
}))
class FieldPanel(EditHandler):
TEMPLATE_VAR = 'field_panel'

Wyświetl plik

@ -0,0 +1,6 @@
<fieldset>
{% if self.heading %}
<legend>{{ self.heading }}</legend>
{% endif %}
<div class="{{ self.classname }}">{{ self.content|safe }}</div>
</fieldset>