mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Add show_panel_furniture() in BoundPanel
This allows TabbedInterface to hide a tab but still render its children
This commit is contained in:
parent
c17ab8b77a
commit
9a1606c809
@ -341,6 +341,12 @@ class Panel:
|
||||
"""
|
||||
return True
|
||||
|
||||
def show_panel_furniture(self):
|
||||
"""
|
||||
Whether this panel shows the panel furniture instead of being rendered outside of it.
|
||||
"""
|
||||
return self.is_shown()
|
||||
|
||||
def is_required(self):
|
||||
return False
|
||||
|
||||
@ -528,6 +534,9 @@ class PanelGroup(Panel):
|
||||
if child.is_shown()
|
||||
]
|
||||
|
||||
def show_panel_furniture(self):
|
||||
return any(child.show_panel_furniture() for child in self.children)
|
||||
|
||||
def is_shown(self):
|
||||
return any(child.is_shown() for child in self.children)
|
||||
|
||||
@ -1082,6 +1091,9 @@ class PublishingPanel(MultiFieldPanel):
|
||||
class BoundPanel(PanelGroup.BoundPanel):
|
||||
template_name = "wagtailadmin/panels/publishing/schedule_publishing_panel.html"
|
||||
|
||||
def show_panel_furniture(self):
|
||||
return False
|
||||
|
||||
|
||||
class CommentPanel(Panel):
|
||||
def get_form_options(self):
|
||||
@ -1158,6 +1170,9 @@ class CommentPanel(Panel):
|
||||
context["comments_data"] = comments_data
|
||||
return context
|
||||
|
||||
def show_panel_furniture(self):
|
||||
return False
|
||||
|
||||
|
||||
# Now that we've defined panels, we can set up wagtailcore.Page to have some.
|
||||
def set_default_page_edit_handlers(cls):
|
||||
|
@ -4,7 +4,10 @@
|
||||
<div class="w-tabs__wrapper">
|
||||
<div role="tablist" class="w-tabs__list">
|
||||
{% for child, identifier in self.visible_children_with_identifiers %}
|
||||
{% include 'wagtailadmin/shared/tabs/tab_nav_link.html' with tab_id=identifier title=child.heading classes=child.classes|join:" " %}
|
||||
{% if child.show_panel_furniture %}
|
||||
{# If there's at least one child that shows the panel furniture, render the tab navigation #}
|
||||
{% include 'wagtailadmin/shared/tabs/tab_nav_link.html' with tab_id=identifier title=child.heading classes=child.classes|join:" " %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@ -22,15 +25,20 @@
|
||||
|
||||
<div class="tab-content">
|
||||
{% for child, identifier in self.visible_children_with_identifiers %}
|
||||
<section
|
||||
id="tab-{{ identifier }}"
|
||||
class="w-tabs__panel {{ child.classes|join:" " }}"
|
||||
role="tabpanel"
|
||||
aria-labelledby="tab-label-{{ identifier }}"
|
||||
hidden
|
||||
>
|
||||
{% if child.show_panel_furniture %}
|
||||
<section
|
||||
id="tab-{{ identifier }}"
|
||||
class="w-tabs__panel {{ child.classes|join:" " }}"
|
||||
role="tabpanel"
|
||||
aria-labelledby="tab-label-{{ identifier }}"
|
||||
hidden
|
||||
>
|
||||
{{ child.render_html }}
|
||||
</section>
|
||||
{% else %}
|
||||
{# If all of the children in the tab do not show the panel furniture, render them without the tab section #}
|
||||
{{ child.render_html }}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user