Changes between Version 39 and Version 40 of S3/S3Report


Ignore:
Timestamp:
05/14/18 12:30:22 (7 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Report

    v39 v40  
    7676
    7777== Report Options ==
    78 Table configurations can contain a `report_options` item, which is a Storage object. This object is used to configure reports and report options form.
    7978
    80 The `rows`, `cols`, `facts` and `aggregate` items are lists of available values for the user to select from.
     79Table configurations can contain a `report_options` item, which is used to configure reports and the report options form.
    8180
    82 The `defaults` property is a Storage object that contains the default values for the report. It can contain a value for `rows`, `cols`, `fact`, `aggregate` and `totals` (as described in [#URLMethods URL Methods]).
     81Report_options can contain `rows`, `cols`, `fact` (+optional `methods`), `defaults` and `precision` properties.
    8382
    84 The `search` property is a list of S3Search widgets that will allow the report to be filtered. If no `search` property is specified, no filter form will be available.
     83The `defaults` property is a dict that contains the default values for the report. It can contain a value for `rows`, `cols`, `fact`, and `totals` (as described in [#URLMethods URL Methods]).
     84
     85The `precision` property can be used to determine the maximum precision of aggregates for a fact field.
    8586
    8687Here is an example of a `report_options` item:
    8788{{{#!python
    88 report_options=Storage(
    89         rows=report_fields,
    90         cols=report_fields,
    91         fact=report_fields,
    92         defaults=Storage(
    93                 rows="project_id",
    94                 cols="name",
    95                 fact="sum(time_actual)",
    96                 # Older versions of S3Report used this syntax (no longer supported):
    97                 #fact="time_actual",
    98                 #aggregate="sum",
    99                 totals=True
    100         ),
    101         search=[
    102                 S3SearchOptionsWidget(
    103                         name="project_id",
    104                         label = T("Project"),
    105                         field = "project_id",
    106                 ),
    107         ],
    108 )
     89report_options = {
     90        "rows": report_fields, # which fields can be pivot table rows (list of selectors)
     91        "cols": report_fields, # which fields can be pivot table columns (list of selectors)
     92        "fact": report_facts,  # possible facts, list of fact descriptors like "method(selector)"
     93        "defaults": {
     94                "rows": "project_id",
     95                "cols": "name",
     96                "fact": "sum(time_actual)",
     97                "totals": True,
     98        },
     99        "precision": {
     100                "time_actual": 2,  # round aggregations of this field to 2 decimals
     101        },
     102}
    109103}}}
    110104
     
    114108
    115109{{{#!python
    116    report_options = Storage(
    117        fact = [selector1, selector2, selector3],
    118        methods = [method1, method2], # methods can be omitted, falls back to a list of all supported methods
     110   report_options = {
     111       "fact": [selector1, selector2, selector3],
     112       "methods": [method1, method2], # methods can be omitted, falls back to a list of all supported methods
    119113       ...
    120    )
     114   }
    121115}}}
    122116
     
    124118
    125119{{{#!python
    126    report_options = Storage(
    127        fact = [
     120   report_options = {
     121       "fact": [
    128122               "method(selector1)",
    129123               "method(selector2)",
    130124               "method(selector3)",
    131                # Older versions of S3Report used this syntax (no longer supported):
    132                #(field1, method1),
    133                #(field2, method1),
    134                #(field2, method2),
    135                #(field3, method1),
    136               ],
     125               ],
    137126       ...
    138    )
     127   }
    139128}}}
    140129
     
    142131
    143132{{{#!python
    144    report_options = Storage(
    145        fact = [
     133   report_options = {
     134       "fact": [
    146135               (T("ReportLabel1"), "method(selector1)"),
    147136               (T("ReportLabel2"), "method(selector2)"),
    148137               (T("ReportLabel3"), "method(selector3)"),
    149                # Older versions of S3Report used this syntax (no longer supported):
    150                #(field1, method1, T("My Report A")),
    151                #(field2, method1, T("My Report B")),
    152                #(field2, method2, T("My Report C")),
    153                #(field3, method1, T("My Report D")),
    154               ],
     138               ],
    155139       ...
    156    )
     140   }
    157141}}}
    158142