From 69d21e3e964c15bf055a65d51a08533aab1da56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Braghi=C8=99?= <31622+zerolab@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:01:32 +0000 Subject: [PATCH] Tidy up the info/warning panel and fix title/no title output (#73) --- cms/core/blocks/panels.py | 12 +++++------- .../components/streamfield/panel_block.html | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/cms/core/blocks/panels.py b/cms/core/blocks/panels.py index 39cf4c84..cc65d631 100644 --- a/cms/core/blocks/panels.py +++ b/cms/core/blocks/panels.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.utils.translation import gettext_lazy as _ from wagtail import blocks @@ -12,20 +13,17 @@ class PanelBlock(blocks.StructBlock): variant = blocks.ChoiceBlock( choices=[ + ("warn", _("Warning")), + ("info", _("Information")), ("announcement", "Announcement"), - ("bare", "Bare"), - ("branded", "Branded"), ("error", "Error"), - ("ghost", "Ghost"), ("success", "Success"), - ("warn-branded", "Warn (branded)"), - ("warn", "Warn"), ], default="warn", ) body = blocks.RichTextBlock(features=settings.RICH_TEXT_BASIC) - title = blocks.CharBlock(required=False, label="Title (optional)") + title = blocks.CharBlock(required=False, label=_("Title (optional)")) class Meta: - label = "Warning or information panel" + label = _("Warning or information panel") template = "templates/components/streamfield/panel_block.html" diff --git a/cms/jinja2/templates/components/streamfield/panel_block.html b/cms/jinja2/templates/components/streamfield/panel_block.html index d85534bc..39d1bd20 100644 --- a/cms/jinja2/templates/components/streamfield/panel_block.html +++ b/cms/jinja2/templates/components/streamfield/panel_block.html @@ -1,9 +1,7 @@ {% from "components/panel/_macro.njk" import onsPanel %} -{# fmt:off #} -{{ onsPanel({ - "variant": value.variant, - "body": value.body, - "title": value.title -}) }} -{# fmt:on #} +{% if value.title %} + {{- onsPanel({"variant": value.variant, "body": value.body, "title": value.title}) -}} +{% else %} + {{- onsPanel({"variant": value.variant, "body": value.body}) -}} +{% endif %}