Skip to main content

jSpreadsheet table blocks for Wagtail

Project description

Wagtail Tables

jspreadsheet tables in Wagtail, edited and customised from the Wagtail admin

Getting started

Assuming you have a Wagtail project up and running:

pip install wagtailtables

Add wagtailtables to your settings.py in the INSTALLED_APPS section, before the core wagtail packages:

INSTALLED_APPS = [
    # ...
    'wagtailtables',
    # ...
]

Add a wagtailtables TableBlock to one of your StreamFields:

from wagtailtables.blocks import TableBlock

class ContentBlocks(StreamBlock):
    table_block = TableBlock()

Include your streamblock in one of your pages

class HomePage(Page):
    body = StreamField(ContentBlocks())

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

Simply render your table block as you would render any other block.

{% load wagtailcore_tags %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-6">
            <h1>{{self.title}}</h1>
            <div class="excerpt">{{self.excerpt|richtext}}</div>
        </div>
    </div>
    {% for block in self.body %}
        {% include_block block %}
    {% endfor %}
</div>
{% endblock %}

Configuration

Customized toolbar

TableBlock accepts a toolbar argument in addition to the standard StructBlock arguments.

The toolbar is an array of dicts, this is the default:

TOOLBAR = [
    {'type': 'i', 'content': 'format_align_left', 'k': 'text-align', 'v': 'left'},
    {'type': 'i', 'content': 'format_align_center', 'k':'text-align', 'v':'center'},
    {'type': 'i', 'content': 'format_align_right', 'k': 'text-align', 'v': 'right'},
    {'type': 'i', 'content': 'format_bold', 'k': 'font-weight', 'v': '600'},
    {'type': 'i', 'content': 'format_italic', 'k': 'font-style', 'v': 'italic'},
    {'type': 'i', 'content': 'border_left', 'k': 'border-left', 'v': '1px solid'},
    {'type': 'i', 'content': 'border_right', 'k': 'border-right', 'v': '1px solid'},
    {'type': 'i', 'content': 'border_top', 'k': 'border-top', 'v': '1px solid'},
]

class ContentBlocks(StreamBlock):
    table_block = TableBlock(toolbar=TOOLBAR)

type should for now always be i for icon, we will provide more types later

content defines the icon (from material icons) click here for all possible keys

k means the style that should be apply to the cell

v means the value of the style should be apply to the cell

Dependencies

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

wagtailtables-0.2.1.tar.gz (174.3 kB view details)

Uploaded Source

Built Distribution

wagtailtables-0.2.1-py3-none-any.whl (179.2 kB view details)

Uploaded Python 3

File details

Details for the file wagtailtables-0.2.1.tar.gz.

File metadata

  • Download URL: wagtailtables-0.2.1.tar.gz
  • Upload date:
  • Size: 174.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for wagtailtables-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d67f01d9dd991de6d3deff1d28669d66ca11dd15f28c1d5f2eea8836969c914a
MD5 28695c6ee283a810428a1d14b858a446
BLAKE2b-256 cd01eb9f244d52bbd3ee3c86d53b35f5ad2cd160f17f0078bc4434ea0368d8fa

See more details on using hashes here.

File details

Details for the file wagtailtables-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtailtables-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f53d1ed9270df5a0a86120b0ad3da63587be6c5bb3d9ca46c44a62178529126
MD5 3557a48d5bc7e735699a028609f2b987
BLAKE2b-256 eb62390c6309c3097f5623f594b938d71047460f9da63fcabc076647340f86e1

See more details on using hashes here.

Supported by

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