Commit 5a50cb9c authored by Jérome Perrin's avatar Jérome Perrin

Make a macro for field value rendering code, for now only used in listbox...

Make a macro for field value rendering code, for now only used in listbox macro, but could also be used for standard fields

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18427 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c3b7cc4a
......@@ -52,20 +52,99 @@
\n
<office:body metal:define-macro="form_layout">\n
<office:spreadsheet>\n
<tal:block metal:define-macro="field">\n
\n
\n
<!-- Render the field in the bottom group. `field` must be defined.\n
The field in the bottom group, can be ListBoxField, MatrixBoxField or a ProxyField to one of thoses.\n
-->\n
<tal:block metal:define-macro="bottom_group_field">\n
<tal:block tal:condition="python: field.meta_type == \'MatrixBox\' or (field.meta_type == \'ProxyField\' and field.getRecursiveTemplateField().meta_type == \'MatrixBox\')">\n
<tal:block tal:define="matrixbox python:field;">\n
<tal:block metal:use-macro="here/matrixbox_ods_macro/macros/matrixbox" />\n
</tal:block>\n
</tal:block>\n
\n
<tal:block tal:condition="python: field.meta_type == \'ListBox\' or (field.meta_type == \'ProxyField\' and field.getRecursiveTemplateField().meta_type == \'ListBox\')">\n
<tal:block tal:define="listbox python:field;" >\n
<tal:block metal:use-macro="here/listbox_ods_macro/macros/listbox" />\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
\n
\n
<!-- Render a value for a field in a Listbox / MatrixBox. `value` must be defined,\n
`field` is optional and is only defined when we have an editable field for this column or cell.\n
-->\n
<tal:block metal:define-macro="cell_value">\n
<tal:block tal:define="is_list python:same_type(value, []) or same_type(value, ());\n
is_float python: isinstance(value, (int, long, float));">\n
\n
\n
<tal:block tal:condition="python: is_list">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
tal:attributes="table:style-name python:is_float and \'figure\' or \'text\'">\n
<text:p tal:condition="python: field is None" \n
tal:content="python: value">\n
</text:p>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(value)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python: value is not None and not is_list">\n
<tal:block tal:condition="is_float">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
tal:attributes="office:value value;\n
table:style-name string:${style_prefix}figure"\n
office:value-type="float"\n
table:style-name="figure">\n
<text:p tal:condition="python: field is None"\n
tal:content="python: value"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(value)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="not: is_float">\n
<tal:block tal:condition="python: isinstance(value, DateTime)">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None);"\n
tal:attributes="office:date-value python: value.strftime(\'%Y-%m-%dT%H:%M:%S\');\n
table:style-name string:${style_prefix}date"\n
table:style-name="date"\n
office:value-type="date">\n
\n
<text:p tal:condition="python: field is None"\n
tal:content="python: value"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(value)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python:not isinstance(value, DateTime)">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
tal:attributes="table:style-name string:${style_prefix}text"\n
table:style-name="text">\n
<text:p tal:condition="python: field is None"\n
tal:content="python: value"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(value)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
<tal:block tal:condition="python: value is None">\n
<table:table-cell office:value-type=\'string\'\n
tal:attributes="table:style-name string:${style_prefix}text"\n
table:style-name=\'text\'\n
table:number-columns-spanned=\'1\'>\n
<text:p tal:content="python: \'\'">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
\n
</tal:block>\n
</tal:block>\n
\n
</office:spreadsheet>\n
</office:body>\n
</tal:block>\n
......
......@@ -141,7 +141,7 @@ dQEAAAAA</string> </value>
</tal:block>\n
<tal:block tal:define="field_list python:form.get_fields_in_group(\'bottom\')">\n
<tal:block tal:repeat="field field_list">\n
<tal:block metal:use-macro="here/field_ods_macro/macros/field" />\n
<tal:block metal:use-macro="here/field_ods_macro/macros/bottom_group_field" />\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
......
......@@ -48,8 +48,7 @@
<tal:block xmlns:draw=\'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\' xmlns:office=\'urn:oasis:names:tc:opendocument:xmlns:office:1.0\' xmlns:text=\'urn:oasis:names:tc:opendocument:xmlns:text:1.0\' xmlns:ooo=\'http://openoffice.org/2004/office\' xmlns:number=\'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\' xmlns:dc=\'http://purl.org/dc/elements/1.1/\' xmlns:meta=\'urn:oasis:names:tc:opendocument:xmlns:meta:1.0\' xmlns:table=\'urn:oasis:names:tc:opendocument:xmlns:table:1.0\' xmlns:dr3d=\'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\' xmlns:fo=\'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\' xmlns:style=\'urn:oasis:names:tc:opendocument:xmlns:style:1.0\' xmlns:xforms=\'http://www.w3.org/2002/xforms\' xmlns:form=\'urn:oasis:names:tc:opendocument:xmlns:form:1.0\' xmlns:script=\'urn:oasis:names:tc:opendocument:xmlns:script:1.0\' xmlns:ooow=\'http://openoffice.org/2004/writer\' xmlns:svg=\'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\' xmlns:chart=\'urn:oasis:names:tc:opendocument:xmlns:chart:1.0\' xmlns:dom=\'http://www.w3.org/2001/xml-events\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:oooc=\'http://openoffice.org/2004/calc\' xmlns:math=\'http://www.w3.org/1998/Math/MathML\' xmlns:tal=\'http://xml.zope.org/namespaces/tal\'\n
xmlns:i18n=\'http://xml.zope.org/namespaces/i18n\'\n
xmlns:metal=\'http://xml.zope.org/namespaces/metal\'\n
tal:attributes=\'dummy python:request.RESPONSE.setHeader("Content-Type", "text/html;;\n
charset=utf-8")\'\n
tal:attributes=\'dummy python:request.RESPONSE.setHeader("Content-Type", "text/html;; charset=utf-8")\'\n
office:version=\'1.0\' metal:define-macro="master">\n
<tal:block metal:use-macro="here/style_macros/macros/style_macro"/>\n
<office:scripts/>\n
......@@ -79,20 +78,24 @@
</tal:block>\n
</tal:block>\n
<tal:block tal:repeat="listboxline python: listboxline_list">\n
<tal:block metal:define-slot="for_form_list" tal:condition="listboxline/isTitleLine | is_report_tree_mode">\n
<tal:block metal:define-slot="for_form_list"\n
tal:condition="listboxline/isTitleLine | is_report_tree_mode">\n
<tal:block metal:define-slot="list_header">\n
<table:table-row table:style-name=\'ro4\'>\n
<tal:block tal:condition="python: is_report_tree_mode">\n
<table:table-cell table:style-name=\'report-column-title\' table:number-columns-spanned=\'1\' office:value-type=\'string\'>\n
<table:table-cell table:style-name=\'report-column-title\'\n
table:number-columns-spanned=\'1\'\n
office:value-type=\'string\'>\n
<tal:block tal:condition="listboxline/getSectionName">\n
<text:p tal:content="listboxline/getSectionName"/>\n
<text:p tal:content="listboxline/getSectionName"/>\n
</tal:block>\n
</table:table-cell>\n
</tal:block>\n
\n
<tal:block tal:condition="listboxline/isTitleLine">\n
<tal:block tal:repeat="column_item listboxline/getColumnItemList">\n
<tal:block tal:define="column_property python: column_item[1]; column_id python: column_item[0]">\n
<tal:block tal:define="column_property python: column_item[1];\n
column_id python: column_item[0]">\n
<table:table-cell table:number-rows-spanned=\'1\' \n
table:style-name=\'report-column-title\'\n
table:number-columns-spanned=\'1\'\n
......@@ -112,95 +115,31 @@
<tal:block tal:condition="python: listboxline.isDataLine() or listboxline.isSummaryLine()">\n
<tal:block tal:repeat="column_item listboxline/getColumnItemList">\n
<tal:block tal:define="column_property python: column_item[1];\n
value column_property;\n
column_id python: column_item[0];\n
is_list python:same_type(column_property, []) or same_type(column_property, ());\n
is_float python: isinstance(column_property, (int, long, float));">\n
<tal:block tal:condition="python: is_list">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
tal:attributes="table:style-name python:is_float and \'report-stat2-sans-bold\' or \'report-content-heading2\'">\n
<text:p tal:condition="python: field is None" tal:content="python: column_property">\n
</text:p>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(column_property)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python: column_property is not None and not is_list">\n
<tal:block tal:condition="is_float">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
tal:attributes="office:value column_property"\n
office:value-type="float"\n
table:style-name="figure">\n
<text:p tal:condition="python: field is None"\n
tal:content="python: column_property"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(column_property)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="not: is_float">\n
<tal:block tal:condition="python: isinstance(column_property, DateTime)">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None);"\n
tal:attributes="office:date-value python: column_property.strftime(\'%Y-%m-%dT%H:%M:%S\')"\n
table:style-name="date"\n
office:value-type="date">\n
\n
<text:p tal:condition="python: field is None"\n
tal:content="python: column_property"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(column_property)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python:not isinstance(column_property, DateTime)">\n
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"\n
table:style-name="report-content-heading2">\n
<text:p tal:condition="python: field is None"\n
tal:content="python: column_property"/>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python: field.render_pdf(column_property)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
<tal:block tal:condition="python: column_property is None">\n
<table:table-cell office:value-type=\'string\' table:style-name=\'report-content-heading2\' table:number-columns-spanned=\'1\'>\n
<text:p tal:content="python: \'\'">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
style_prefix string:;\n
field python: editable_fields.get(column_id, None);">\n
<tal:block metal:use-macro="here/field_ods_macro/macros/cell_value"/>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
\n
<tal:block tal:condition="python: listboxline.isStatLine() or listboxline.isSummaryLine()">\n
<tal:block tal:repeat="column_item python: listboxline.getColumnItemList()">\n
<tal:block tal:define="column_property python: column_item[1];\n
column_id python: column_item[0]">\n
<tal:block tal:condition="python: column_property is not None">\n
<!-- TODO: use a macro for field value rendering -->\n
<table:table-cell table:style-name="report-stat2-sans-bold-with-lines"\n
table:number-columns-spanned=\'1\'\n
tal:define="field python: editable_fields.get(column_id, None)"> \n
<text:p tal:condition="python: field is None"\n
tal:content="python: column_property">\n
</text:p>\n
<text:p tal:condition="python: field is not None"\n
tal:content="python:field.render_pdf(column_property)">\n
</text:p>\n
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python: column_property is None">\n
<table:table-cell table:style-name="report-stat2-sans-bold-with-lines"\n
table:number-columns-spanned=\'1\' >\n
</table:table-cell>\n
</tal:block>\n
value column_property;\n
column_id python: column_item[0];\n
style_prefix string:stat-;\n
field python: editable_fields.get(column_id, None);">\n
<tal:block metal:use-macro="here/field_ods_macro/macros/cell_value"/>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
</table:table-row>\n
</tal:block>\n
</tal:block>\n
\n
\n
<table:table-row metal:define-slot="table_bottom_line">\n
<tal:block tal:repeat="listboxline python: listboxline_list">\n
<tal:block tal:condition="listboxline/isTitleLine">\n
......
......@@ -62,7 +62,7 @@
global column_len python:5">\n
<!-- TODO: calculate column_len based on the first listbox (or selection_column if exists)-->\n
\n
<tal:block tal:define="portal_object here/portal_url/getPortalObject"> \n
<tal:block tal:define="portal_object here/portal_url/getPortalObject">\n
<tal:block tal:condition="not: sheet_per_reportsection">\n
<table:table tal:attributes="table:name python:here.getProperty(\'title\')">\n
<!-- at least one table-column element is required for ODF to validate -->\n
......
106
\ No newline at end of file
108
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment