0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

make the code for joining a list of classnames with spaces a bit less enterprisey

This commit is contained in:
Matt Westcott 2023-09-20 15:38:03 +01:00 committed by Matt Westcott
parent 276d0c1a2b
commit 26c2e686f1
2 changed files with 3 additions and 7 deletions

View File

@ -1,6 +1,4 @@
{% load wagtailadmin_tags %}
{% fragment as toggle_classname %}{{ classes|join:' ' }}{% endfragment %}
{% dropdown attrs=self.attrs toggle_icon=icon_name|default:"arrow-down" toggle_label=label toggle_aria_label=title toggle_classname=toggle_classname %}
{% include "wagtailadmin/pages/listing/_dropdown_items.html" with buttons=buttons only %}
{% enddropdown %}

View File

@ -87,6 +87,8 @@ class PageListingButton(ListingButton):
class BaseDropdownMenuButton(Button):
template_name = "wagtailadmin/pages/listing/_button_with_dropdown.html"
def __init__(self, *args, **kwargs):
super().__init__(*args, url=None, **kwargs)
@ -99,22 +101,18 @@ class BaseDropdownMenuButton(Button):
"buttons": self.dropdown_buttons,
"label": self.label,
"title": self.aria_label,
"classes": self.classes,
"toggle_classname": " ".join(self.classes),
"icon_name": self.icon_name,
}
class ButtonWithDropdown(BaseDropdownMenuButton):
template_name = "wagtailadmin/pages/listing/_button_with_dropdown.html"
def __init__(self, *args, **kwargs):
self.dropdown_buttons = kwargs.pop("buttons", [])
super().__init__(*args, **kwargs)
class ButtonWithDropdownFromHook(BaseDropdownMenuButton):
template_name = "wagtailadmin/pages/listing/_button_with_dropdown.html"
def __init__(self, label, hook_name, page, page_perms, next_url=None, **kwargs):
self.hook_name = hook_name
self.page = page