Skip to main content

This Wagtail app provides several ui improvements to the Wagtail admin.

Project description

Wagtail UI Plus

This Wagtail app provides several ui improvements to the Wagtail admin.

Conditional checkboxes

  • Automatically check a target checkbox whenever a trigger checkbox is checked
  • The reverse also applies, when the target checkbox is unchecked, the trigger checkbox is also unchecked
  • This functionality can be used to create an "all" option among a list of checkboxes
  • Supported trigger elements: BooleanField
  • Supported target elements: BooleanField (on the same tab)

Conditional visibility

  • Show or hide form fields based on conditional visibility rules
  • Regular page fields:
    • Supported trigger elements: CharField (with choices), BooleanField
    • Supported target elements: Any subclass of EditHandler (on the same tab)
  • Struct block fields:
    • Supported trigger elements: ChoiceBlock
    • Supported target elements: Any subclass of FieldBlock (within the same struct block)

Collapsable panels

  • Click on the panel header to collapse/expand the panel
  • Set the default collapsed state
  • Supported panels: MultiFieldPanel and StreamFieldPanel

Stream field improvements

  • Added borders around blocks
  • Added panel-style headers to blocks
  • Added spacing between blocks
  • Permanently visible add buttons
  • Use more of the available space for blocks
  • Supported blocks: CharBlock, TextBlock, EmailBlock, IntegerBlock, FloatBlock, DecimalBlock, RegexBlock, URLBlock, BooleanBlock, DateBlock, TimeBlock, DateTimeBlock, RichTextBlock, RawHTMLBlock, BlockQuoteBlock, ChoiceBlock, PageChooserBlock, DocumentChooserBlock, ImageChooserBlock, SnippetChooserBlock, EmbedBlock, StaticBlock, StructBlock and StreamBlock

Struct block improvements

  • All of the above stream field improvements
  • If the first field in the struct block is a CharBlock, TextBlock or RichtTextBlock, show it's value in the block header after the block type
  • Click on the block header to collapse/expand the struct block
  • All struct blocks are default collapsed on page load, but newly added blocks are default expanded

Compatibility

  • Wagtail 2.6.2

Installation

  • pip install wagtailuiplus
  • Add wagtailuiplus to your installed apps

Usage

Conditional checkboxes

  • Add the class wagtailuiplus__checkbox-handler to the trigger element
  • Add the class wagtailuiplus__checkbox-handler--{block_name} to the trigger element, where {block_name} is equal to the block name of the trigger element
  • Add the class wagtailuiplus__checkbox-handler-target--{block_name} to each target element, where {block_name} is equal to the block name of the trigger element
  • Add conditional visibility rules to the target elements

To check a target checkbox when the trigger field is checked:

  • Add the class wagtailuiplus__checkbox-handler-checked-if--checked to the target element

Screenshot

Conditional visibility

Steps to configure conditional visibility rules:

  • Add the class wagtailuiplus__choice-handler to the trigger element
  • Add the class wagtailuiplus__choice-handler--{block_name} to the trigger element, where {block_name} is equal to the block name of the trigger element
  • Add the class wagtailuiplus__choice-handler-target--{block_name} to each target element, where {block_name} is equal to the block name of the trigger element
  • Add conditional visibility rules to the target elements

To hide a target element if the trigger field has a certain value:

  • Add the class wagtailuiplus__choice-handler-hidden-if--{value} to the target element, where {value} is the value of the trigger element

To match the values of a BooleanField, use the string value true or false. Multiple rules on the same target element are treated as an or, 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'
        ),
    )

Screenshot

Collapsable panels

The panels automatically become collapsable. To set the initial collapsed state of panels, add the wagtailuiplus__panel--collapsed classname to the panel, for example:

class HomePage(Page):
    content_panels = [
        MultiFieldPanel([
            FieldPanel('title'),
        ], 'My multi field panel', classname='wagtailuiplus__panel--collapsed'),
    ]

Screenshot

StreamField UI improvements

The 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'),
    ]

Screenshot

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtailuiplus-1.3.11.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtailuiplus-1.3.11-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file wagtailuiplus-1.3.11.tar.gz.

File metadata

  • Download URL: wagtailuiplus-1.3.11.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.1

File hashes

Hashes for wagtailuiplus-1.3.11.tar.gz
Algorithm Hash digest
SHA256 09ae517809dc22293bcbd5fc60436a46ff9dd75981ff327f12284d44c599e075
MD5 ddb4ae8d43d00428d7dca1bd2a9c64b8
BLAKE2b-256 e171b3565d3d2868a7343ff5178a5fae72417f5b878201b56d6d743175e48e0a

See more details on using hashes here.

File details

Details for the file wagtailuiplus-1.3.11-py3-none-any.whl.

File metadata

  • Download URL: wagtailuiplus-1.3.11-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.1

File hashes

Hashes for wagtailuiplus-1.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 5a20a12d7091435f9a078fa6194a73e0db91f98edb7ad63d47431ad64597067e
MD5 35189d7b4c3249fef5e60775ce41cd60
BLAKE2b-256 d155077b3f371dd1c4aa1aad6f4fefd00795da9635035156475d074dc64b6d3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page