Package: wagtailuiplus
Wagtail UI PlusThis Wagtail app provides several ui improvements to the Wagtail admin.Conditional checkboxesAutomatically check a target checkbox whenever a trigger checkbox is checkedThe reverse also applies, when the target checkbox is unchecked, the trigger checkbox is also uncheckedThis functionality can be used to create an "all" option among a list of checkboxesSupported trigger elements:BooleanFieldSupported target elements:BooleanFieldConditional visibilityShow or hide form fields based on conditional visibility rulesRegular page fields:Supported trigger elements:CharField(with choices),BooleanFieldSupported target elements: Any subclass ofEditHandlerStruct block fields:Supported trigger elements:ChoiceBlockSupported target elements: Any subclass ofFieldBlock(within the same struct block)Collapsable panelsClick on the panel header to collapse/expand the panelSet the default collapsed stateSupported panels:MultiFieldPanelandStreamFieldPanelStream field improvementsAdded borders around blocksAdded panel-style headers to blocksAdded spacing between blocksPermanently visible add buttonsUse more of the available space for blocksSupported blocks:CharBlock,TextBlock,EmailBlock,IntegerBlock,FloatBlock,DecimalBlock,RegexBlock,URLBlock,BooleanBlock,DateBlock,TimeBlock,DateTimeBlock,RichTextBlock,RawHTMLBlock,BlockQuoteBlock,ChoiceBlock,PageChooserBlock,DocumentChooserBlock,ImageChooserBlock,SnippetChooserBlock,EmbedBlock,StaticBlock,StructBlockandStreamBlockStruct block improvementsAll of the above stream field improvementsIf the first field in the struct block is aCharBlock,TextBlockorRichtTextBlock, show it's value in the block header after the block typeClick on the block header to collapse/expand the struct blockAll struct blocks are default collapsed on page load, but newly added blocks are default expandedCompatibilityWagtail 2.6.2Installationpip install wagtailuiplusAddwagtailuiplusto your installed appsUsageConditional checkboxesAdd the classwagtailuiplus__checkbox-handlerto the trigger elementAdd the classwagtailuiplus__checkbox-handler--{block_name}to the trigger element, where{block_name}is equal to the block name of the trigger elementAdd the classwagtailuiplus__checkbox-handler-target--{block_name}to each target element, where{block_name}is equal to the block name of the trigger elementAdd conditional visibility rules to the target elementsTo check a target checkbox when the trigger field is checked:Add the classwagtailuiplus__checkbox-handler-checked-if--checkedto the target elementConditional visibilitySteps to configure conditional visibility rules:Add the classwagtailuiplus__choice-handlerto the trigger elementAdd the classwagtailuiplus__choice-handler--{block_name}to the trigger element, where{block_name}is equal to the block name of the trigger elementAdd the classwagtailuiplus__choice-handler-target--{block_name}to each target element, where{block_name}is equal to the block name of the trigger elementAdd conditional visibility rules to the target elementsTo hide a target element if the trigger field has a certain value:Add the classwagtailuiplus__choice-handler-hidden-if--{value}to the target element, where{value}is the value of the trigger elementTo match the values of aBooleanField, use the string valuetrueorfalse. Multiple rules on the same target element are treated as anor, so if any of the rules match, the element is hidden. In the following example, conditional visibility is used to show a page chooser when building an internal link, or show a text input when building an external link:class LinkBlock(StructBlock):
    link_type = ChoiceBlock(
        choices = [
            ('internal', 'Internal link'),
            ('external', 'External link'),
        ],
        required=True,
        default='internal',
        label='Link type',
        classname=(
            'wagtailuiplus__choice-handler '
            'wagtailuiplus__choice-handler--link_type'
        )
    )
    link_page = PageChooserBlock(
        required=False,
        label='Link page',
        classname=(
            'wagtailuiplus__choice-handler-target--link_type '
            'wagtailuiplus__choice-handler-hidden-if--external'
        ),
    )
    link_url = CharBlock(
        required=False,
        label='Link url',
        classname=(
            'wagtailuiplus__choice-handler-target--link_type '
            'wagtailuiplus__choice-handler-hidden-if--internal'
        ),
    )Collapsable panelsThe panels automatically become collapsable. To set the initial collapsed state of panels, add thewagtailuiplus__panel--collapsedclassname to the panel, for example:class HomePage(Page):
    content_panels = [
        MultiFieldPanel([
            FieldPanel('title'),
        ], 'My multi field panel', classname='wagtailuiplus__panel--collapsed'),
    ]StreamField UI improvementsThe UI improvements automatically apply. Just create your StreamField as usual, for example:from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core.blocks import (
  CharBlock,
  StreamBlock,
  StructBlock,
  RichTextBlock,
)
from wagtail.core.fields import StreamField
from wagtail.core.models import Page


class MyCharBlock(CharBlock):
    class Meta:
        icon = 'pilcrow'
        label = 'My char block'


class MyRichTextBlock(RichTextBlock):
    class Meta:
        icon = 'openquote'
        label = 'My rich text block'


class MyStreamBlock(StreamBlock):
    title = MyCharBlock()
    text = MyRichTextBlock()

    class Meta:
        label = 'My stream block'


class MyStructBlock(StructBlock):
    items = MyStreamBlock(required=False)

    class Meta:
        icon = 'list-ul'
        label = 'My struct block'


class HomePage(Page):
    my_stream_field = StreamField([
            ('my_title_block', MyCharBlock()),
            ('my_text_block', MyRichTextBlock()),
            ('my_struct_block', MyStructBlock()),
        ], blank=True, verbose_name='My stream field')

    content_panels = [
        StreamFieldPanel('my_stream_field'),
    ]