wiki:S3/S3Summary

Version 13 (modified by Dominic König, 11 years ago) ( diff )

--

S3Summary: Summary Pages

A summary page is a single-resource, multi-record view with multiple embedded data presentations ("widgets", e.g. tables, maps, charts) and a common filter form.

The general structure of a summary page is:

Sections

The summary page can be broken up into sections (optional), each of which containing one or more widgets.

Multiple sections are rendered with a tab-style navigation, with only one section visible at a time. An additional "common" section is always visible.

Number, type and contents of the sections are freely configurable.

Widgets

Widgets are presentations of the resource data, e.g. as tables, maps or charts.

The summary framework does not render the widgets itself, but invokes the widget() interface of regular REST method handlers (e.g. S3CRUD, S3Map, S3Report) to generate them.

The type and order of widgets are freely configurable.

Filtering

All widgets can be filtered simultaneously with a common filter form.

The summary framework features lazy-refresh, so that only visible widgets are refreshed immediately after a filter change, while the hidden widgets are scheduled for refresh when they become visible. This reduces the load for server and network to what is really necessary.

The summary framework does not render or control the filter form itself, but uses the S3Filter framework to generate the form and apply the filters.

Configuration

The summary page configuration is a deployment setting:

settings.ui.summary = [...]

It takes a list of section configurations as value, or None.

The deployment setting can be overridden per resource:

s3db.configure(tablename, summary = [...])

A useful technique is to extend the deployment settings for a particular resource as needed:

# Get the default configuration
summary = list(current.deployment_settings.get_ui_summary() or [])
# Extend with resource-specific sections
summary.extend([...])
s3db.configure(tablename, summary = summary)

Sections Configuration

Each section configuration is a dict:

settings.ui.summary = [{"name": "table",    # the section name, must be unique
                        "label": "Table",   # the section label, will automatically be translated
                        "common": False,    # show this section on all tabs
                        "translate": True,  # turn automatic label translation on/off (default=True)
                        "widgets": [...],   # list of widgets for this section
                        },
                        {...}, # next section
                        ...
                       ]

Sections are rendered in the order in which they are configured.

Widget Configuration

Each widget configuration is a dict in the "widgets" list of a section:

settings.ui.summary = [{"name": "table",
                        "label": "Table",
                        "common": False,
                        "translate": True,
                        "widgets": [                # List of widgets for this section

                           {"method": "datatable",  # Widget method, either a name that resolves into
                                                    # a S3Method, or a callable to render the widget

                            "filterable": True,     # Whether the widget can be filtered by the summary
                                                    # filter form

                            "ajax_init": False,     # Whether the widget requires an Ajax-request to initialize
                                                    # True for "report" and "map" widgets
                            },
                           {...},                   # Next widget
                         ],
                        },
                       ]

If a method name is passed for "method", it is important that the corresponding method handler implements the widget() interface.

Instead of a name, you can also specify a callable that returns either HTML content, or a dict of variables for the view template.

Code

Future Extensions

See Also

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.