mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 03:31:04 +01:00
Adds a new HelpPanel (#4374)
This commit is contained in:
parent
a46ba4805b
commit
d188576af8
@ -281,6 +281,7 @@ Contributors
|
||||
* Todd Dembrey
|
||||
* Sebastian Brestin
|
||||
* Casper Timmers
|
||||
* Kevin Chung
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
@ -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
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
<fieldset>
|
||||
{% if self.heading %}
|
||||
<legend>{{ self.heading }}</legend>
|
||||
{% endif %}
|
||||
<div class="{{ self.classname }}">{{ self.content|safe }}</div>
|
||||
</fieldset>
|
Loading…
Reference in New Issue
Block a user