| | 35 | The summary page configuration is a deployment setting: |
| | 36 | |
| | 37 | {{{#!python |
| | 38 | settings.ui.summary = [...] |
| | 39 | }}} |
| | 40 | |
| | 41 | It takes a list of section configurations as value, or None. |
| | 42 | |
| | 43 | The deployment setting can be overridden per resource: |
| | 44 | {{{#!python |
| | 45 | s3db.configure(tablename, summary = [...]) |
| | 46 | }}} |
| | 47 | |
| | 48 | A useful technique is to extend the deployment settings for a particular resource as needed: |
| | 49 | {{{#!python |
| | 50 | # Get the default configuration |
| | 51 | summary = list(current.deployment_settings.get_ui_summary() or []) |
| | 52 | # Extend with resource-specific sections |
| | 53 | summary.extend([...]) |
| | 54 | s3db.configure(tablename, summary = summary) |
| | 55 | }}} |
| | 56 | |
| | 57 | === Sections Configuration === |
| | 58 | |
| | 59 | Each section configuration is a dict: |
| | 60 | {{{#!python |
| | 61 | settings.ui.summary = [{"name": "table", # the section name, must be unique |
| | 62 | "label": "Table", # the section label, will automatically be translated |
| | 63 | "common": False, # show this section on all tabs |
| | 64 | "translate": True, # turn automatic label translation on/off (default=True) |
| | 65 | "widgets": [...], # list of widgets for this section |
| | 66 | }, |
| | 67 | {...}, # next section |
| | 68 | ... |
| | 69 | ] |
| | 70 | }}} |
| | 71 | |
| | 72 | Sections are rendered in the order in which they are configured. |
| | 73 | |
| | 74 | === Widget Configuration === |
| | 75 | |
| | 76 | Each widget configuration is a dict in the "widgets" list of a section: |
| | 77 | {{{#!python |
| | 78 | settings.ui.summary = [{"name": "table", |
| | 79 | "label": "Table", |
| | 80 | "common": False, |
| | 81 | "translate": True, |
| | 82 | "widgets": [ |
| | 83 | {"method": "datatable", # widget method, either a name that resolves into |
| | 84 | # a S3Method, or a callable to render the widget |
| | 85 | |
| | 86 | "filterable": True, # Whether the widget can be filtered by the summary |
| | 87 | # filter form |
| | 88 | |
| | 89 | "ajax_init": False, # Whether the widget requires an Ajax-request to initialize |
| | 90 | # True for "report" and "map" widgets |
| | 91 | }, |
| | 92 | {...}, # Next widget |
| | 93 | ], |
| | 94 | }, |
| | 95 | ] |
| | 96 | }}} |
| | 97 | |
| | 98 | If a method name is passed for "method", it is important that the corresponding method handler implements the widget() interface. |
| | 99 | |
| | 100 | Instead of a name, you can also specify a callable that returns either HTML content, or a dict of variables for the view template. |