Commit a00c4dae authored by Jérome Perrin's avatar Jérome Perrin

ods_style: cleanup field_ods_macro/macros/cell_value

remove useless `field python: editable_fields.get(column_id, None)`
tal:defines, the macro always documented `field` as required and all
callers pass it.

document that `style_prefix` is required
parent 4a1d8177
...@@ -95,17 +95,17 @@ ...@@ -95,17 +95,17 @@
</table:table-row> </table:table-row>
</tal:block> </tal:block>
<!-- Render a value for a field in a Listbox / MatrixBox. `value` must be defined, <!--
`field` is optional and is only defined when we have an editable field for this column or cell. Render a value for a field in a Listbox / MatrixBox.
`value` must be defined
`style_prefix` must be defined
`field` is optional and is only defined when we have an editable field for this column or cell.
--> -->
<tal:block metal:define-macro="cell_value"> <tal:block metal:define-macro="cell_value">
<tal:block tal:define="is_list python:same_type(value, []) or same_type(value, ()); <tal:block tal:define="is_list python:same_type(value, []) or same_type(value, ());
is_float python: isinstance(value, modules['six'].integer_types + (float,));"> is_float python: isinstance(value, modules['six'].integer_types + (float, ));">
<tal:block tal:condition="python: is_list"> <tal:block tal:condition="python: is_list">
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)" <table:table-cell tal:attributes="table:style-name python:is_float and 'figure' or 'text'">
tal:attributes="table:style-name python:is_float and 'figure' or 'text'">
<tal:block tal:condition="python: field is None" tal:repeat="item value"> <tal:block tal:condition="python: field is None" tal:repeat="item value">
<text:p tal:content="item"/> <text:p tal:content="item"/>
</tal:block> </tal:block>
...@@ -117,8 +117,7 @@ ...@@ -117,8 +117,7 @@
<tal:block tal:condition="python: value is not None and not is_list"> <tal:block tal:condition="python: value is not None and not is_list">
<tal:block tal:condition="is_float"> <tal:block tal:condition="is_float">
<tal:block tal:condition="python: isinstance(value, modules['six'].integer_types)"> <tal:block tal:condition="python: isinstance(value, modules['six'].integer_types)">
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)" <table:table-cell tal:attributes="office:value value;
tal:attributes="office:value value;
table:style-name string:${style_prefix}figure" table:style-name string:${style_prefix}figure"
office:value-type="float" office:value-type="float"
table:style-name="figure"> table:style-name="figure">
...@@ -130,86 +129,81 @@ ...@@ -130,86 +129,81 @@
</table:table-cell> </table:table-cell>
</tal:block> </tal:block>
<tal:block tal:condition="python: isinstance(value, float)"> <tal:block tal:condition="python: isinstance(value, float)">
<tal:block tal:define="field python: editable_fields.get(column_id, None)"> <tal:block tal:condition="python: field is not None">
<tal:block tal:condition="python: field is not None"> <tal:block tal:condition="python:field.meta_type in ['FloatField','IntegerField'] or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type in ['FloatField','IntegerField'])">
<tal:block tal:condition="python:field.meta_type in ['FloatField','IntegerField'] or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type in ['FloatField','IntegerField'])"> <tal:block tal:define="precision python: (field.meta_type == 'FloatField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'FloatField')) and field.get_value('precision') or 0;
<tal:block tal:define="precision python: (field.meta_type == 'FloatField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'FloatField')) and field.get_value('precision') or 0; figure_style_name string:${style_prefix}figure_${precision};
figure_style_name string:${style_prefix}figure_${precision}; input_style python: (field.meta_type == 'FloatField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'FloatField')) and field.get_value('input_style') or ''">
input_style python: (field.meta_type == 'FloatField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'FloatField')) and field.get_value('input_style') or ''"> <table:table-cell tal:attributes="office:value value;
<table:table-cell tal:attributes="office:value value; table:style-name figure_style_name;
table:style-name figure_style_name; office:value-type python: ('%' in input_style) and 'percentage' or 'float'"
office:value-type python: ('%' in input_style) and 'percentage' or 'float'" table:style-name="figure">
table:style-name="figure"> <text:p tal:content="python: field.render_pdf(value)" />
<text:p tal:content="python: field.render_pdf(value)" /> </table:table-cell>
</table:table-cell> </tal:block>
</tal:block> <tal:block tal:condition="python:field.meta_type not in ['FloatField','IntegerField'] and field.meta_type!='ProxyField'">
<tal:block tal:condition="python:field.meta_type not in ['FloatField','IntegerField'] and field.meta_type!='ProxyField'"> <table:table-cell tal:attributes="table:style-name string:${style_prefix}string;"
<table:table-cell tal:attributes="table:style-name string:${style_prefix}string;" table:style-name="string"
table:style-name="string" office:value-type="string">
office:value-type="string"> <text:p>Error: field is not a FloatField nor an IntegerField</text:p>
<text:p>Error: field is not a FloatField nor an IntegerField</text:p> </table:table-cell>
</table:table-cell>
</tal:block>
</tal:block> </tal:block>
</tal:block> </tal:block>
<tal:block tal:condition="python: field is None"> </tal:block>
<table:table-cell tal:attributes="office:value value; <tal:block tal:condition="python: field is None">
table:style-name string:${style_prefix}figure" <table:table-cell tal:attributes="office:value value;
office:value-type="float" table:style-name string:${style_prefix}figure"
table:style-name="figure"> office:value-type="float"
<text:p tal:condition="python: field is None" table:style-name="figure">
tal:content="python: value"/> <text:p tal:condition="python: field is None"
<text:p tal:condition="python: field is not None" tal:content="python: value"/>
tal:content="python: field.render_pdf(value)"> <text:p tal:condition="python: field is not None"
</text:p> tal:content="python: field.render_pdf(value)">
</table:table-cell> </text:p>
</tal:block> </table:table-cell>
</tal:block> </tal:block>
</tal:block> </tal:block>
</tal:block> </tal:block>
<tal:block tal:condition="not: is_float"> <tal:block tal:condition="not: is_float">
<tal:block tal:condition="python: isinstance(value, DateTime)"> <tal:block tal:condition="python: isinstance(value, DateTime)">
<tal:block tal:define="field python: editable_fields.get(column_id, None);"> <tal:block tal:condition="python: field is None">
<tal:block tal:condition="python: field is None"> <table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value); table:style-name string:${style_prefix}date;"
table:style-name string:${style_prefix}date;" table:style-name="date"
office:value-type="date">
<text:p tal:content="python: value"/>
</table:table-cell>
</tal:block>
<tal:block tal:condition="python: field is not None">
<tal:block tal:condition="python:field.meta_type=='DateTimeField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'DateTimeField')">
<tal:block tal:condition="python:field.get_value('date_only')">
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);
table:style-name string:${style_prefix}date;"
table:style-name="date" table:style-name="date"
office:value-type="date"> office:value-type="date">
<text:p tal:content="python: value"/> <text:p tal:content="python: field.render_pdf(value)"/>
</table:table-cell> </table:table-cell>
</tal:block>
<tal:block tal:condition="python: field is not None">
<tal:block tal:condition="python:field.meta_type=='DateTimeField' or (field.meta_type == 'ProxyField' and field.getRecursiveTemplateField().meta_type == 'DateTimeField')">
<tal:block tal:condition="python:field.get_value('date_only')">
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);
table:style-name string:${style_prefix}date;"
table:style-name="date"
office:value-type="date">
<text:p tal:content="python: field.render_pdf(value)"/>
</table:table-cell>
</tal:block>
<tal:block tal:condition="python:not field.get_value('date_only')">
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);
table:style-name string:${style_prefix}date_with_time;"
table:style-name="date_with_time"
office:value-type="date">
<text:p tal:content="python: field.render_pdf(value)"/>
</table:table-cell>
</tal:block>
</tal:block> </tal:block>
<tal:block tal:condition="python:field.meta_type!='DateTimeField' and field.meta_type!='ProxyField'"> <tal:block tal:condition="python:not field.get_value('date_only')">
<table:table-cell tal:attributes="table:style-name string:${style_prefix}string;" <table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);
table:style-name="string" table:style-name string:${style_prefix}date_with_time;"
office:value-type="string"> table:style-name="date_with_time"
<text:p>Error: field is not a DateTimeField</text:p> office:value-type="date">
<text:p tal:content="python: field.render_pdf(value)"/>
</table:table-cell> </table:table-cell>
</tal:block> </tal:block>
</tal:block> </tal:block>
<tal:block tal:condition="python:field.meta_type!='DateTimeField' and field.meta_type!='ProxyField'">
<table:table-cell tal:attributes="table:style-name string:${style_prefix}string;"
table:style-name="string"
office:value-type="string">
<text:p>Error: field is not a DateTimeField</text:p>
</table:table-cell>
</tal:block>
</tal:block> </tal:block>
</tal:block> </tal:block>
<tal:block tal:condition="python:not isinstance(value, DateTime)"> <tal:block tal:condition="python:not isinstance(value, DateTime)">
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)" <table:table-cell tal:attributes="table:style-name string:${style_prefix}text"
tal:attributes="table:style-name string:${style_prefix}text"
table:style-name="text"> table:style-name="text">
<text:p tal:condition="python: field is None" <text:p tal:condition="python: field is None"
tal:content="python: value"/> tal:content="python: value"/>
......
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