Commit b72e466d authored by Alexandre Boeglin's avatar Alexandre Boeglin

Reverted previous patch, as it is not the right way to do.

We must instead use css style and formatting of widgets defined as editable
  columns for the ListBox.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3391 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 203054d6
...@@ -254,7 +254,6 @@ class ListBoxWidget(Widget.Widget): ...@@ -254,7 +254,6 @@ class ListBoxWidget(Widget.Widget):
property_names = Widget.Widget.property_names +\ property_names = Widget.Widget.property_names +\
['lines', 'columns', 'all_columns', 'search_columns', 'sort_columns', 'sort', ['lines', 'columns', 'all_columns', 'search_columns', 'sort_columns', 'sort',
'editable_columns', 'all_editable_columns', 'stat_columns', 'url_columns', 'global_attributes', 'editable_columns', 'all_editable_columns', 'stat_columns', 'url_columns', 'global_attributes',
'force_alignment', 'float_rounding',
'list_method', 'count_method', 'stat_method', 'selection_name', 'list_method', 'count_method', 'stat_method', 'selection_name',
'meta_types', 'portal_types', 'default_params', 'meta_types', 'portal_types', 'default_params',
'search', 'select', 'search', 'select',
...@@ -407,20 +406,6 @@ class ListBoxWidget(Widget.Widget): ...@@ -407,20 +406,6 @@ class ListBoxWidget(Widget.Widget):
default=[], default=[],
required=0) required=0)
force_alignment = fields.ListTextAreaField('force_alignment',
title="Force Alignment",
description=(
"An optional list of alignment values used when defined"),
default=[],
required=0)
float_rounding = fields.ListTextAreaField('float_rounding',
title="Float Rounding",
description=(
"An optional list of rounding values used for float fields"),
default=[],
required=0)
domain_tree = fields.CheckBoxField('domain_tree', domain_tree = fields.CheckBoxField('domain_tree',
title='Domain Tree', title='Domain Tree',
description=('Selection Tree'), description=('Selection Tree'),
...@@ -510,8 +495,6 @@ class ListBoxWidget(Widget.Widget): ...@@ -510,8 +495,6 @@ class ListBoxWidget(Widget.Widget):
all_editable_columns = field.get_value('all_editable_columns') all_editable_columns = field.get_value('all_editable_columns')
stat_columns = field.get_value('stat_columns') stat_columns = field.get_value('stat_columns')
url_columns = field.get_value('url_columns') url_columns = field.get_value('url_columns')
force_alignment = field.get_value('force_alignment')
float_rounding = field.get_value('float_rounding')
search_columns = field.get_value('search_columns') search_columns = field.get_value('search_columns')
sort_columns = field.get_value('sort_columns') sort_columns = field.get_value('sort_columns')
domain_tree = field.get_value('domain_tree') domain_tree = field.get_value('domain_tree')
...@@ -585,12 +568,6 @@ class ListBoxWidget(Widget.Widget): ...@@ -585,12 +568,6 @@ class ListBoxWidget(Widget.Widget):
if not url_columns: if not url_columns:
url_columns = [] url_columns = []
if not force_alignment:
force_alignment = []
if not float_rounding:
float_rounding = []
has_catalog_path = None has_catalog_path = None
for (k, v) in all_columns: for (k, v) in all_columns:
if k == 'catalog.path' or k == 'path': if k == 'catalog.path' or k == 'path':
...@@ -1682,41 +1659,20 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1682,41 +1659,20 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
attribute_value = "Could not evaluate" attribute_value = "Could not evaluate"
attribute_original_value = None attribute_original_value = None
#LOG('ListBox', 0, 'o = %s' % repr(dir(o))) #LOG('ListBox', 0, 'o = %s' % repr(dir(o)))
# Alignment
if sql in [x[0] for x in force_alignment]:
try:
alignment_index = [x[0] for x in force_alignment].index(sql)
forced_alignment = force_alignment[alignment_index][1]
except ValueError:
forced_alignment = left
td_align = forced_alignment
elif type(attribute_value) is type(0.0):
td_align = "right"
elif type(attribute_value) is type(1):
td_align = "right"
else:
td_align = "left"
# Float numbers rounding
if type(attribute_value) is type(0.0): if type(attribute_value) is type(0.0):
attribute_original_value = attribute_value attribute_original_value = attribute_value
if sql in editable_column_ids and form.has_field('%s_%s' % (field.id, alias) ): if sql in editable_column_ids and form.has_field('%s_%s' % (field.id, alias) ):
# Do not truncate if editable # Do not truncate if editable
pass pass
else: else:
if sql in [x[0] for x in float_rounding]: #attribute_original_value = attribute_value
try: attribute_value = "%.2f" % attribute_value
rounding_index = [x[0] for x in float_rounding].index(sql) td_align = "right"
round = float_rounding[rounding_index][1]
except:
round = 2
else:
round = 2
try:
attribute_value = "%%.%sf" % round % attribute_value
except ValueError:
attribute_value = "%.2f" % attribute_value
elif type(attribute_value) is type(1): elif type(attribute_value) is type(1):
attribute_original_value = attribute_value attribute_original_value = attribute_value
td_align = "right"
else:
td_align = "left"
# It is safer to convert attribute_value to an unicode string, because # It is safer to convert attribute_value to an unicode string, because
# it might be utf-8. # it might be utf-8.
if type(attribute_value) == type(''): if type(attribute_value) == type(''):
...@@ -1752,17 +1708,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1752,17 +1708,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if type(cell_body) == type(''): if type(cell_body) == type(''):
cell_body = unicode(cell_body, 'utf-8') cell_body = unicode(cell_body, 'utf-8')
#LOG('ListBox', 0, 'cell_body = %r, error_message = %r' % (cell_body, error_message)) #LOG('ListBox', 0, 'cell_body = %r, error_message = %r' % (cell_body, error_message))
# Alignment list_body += ('<td class=\"%s%s\">%s%s</td>' % (td_css, error_css, cell_body, error_message))
if sql in [x[0] for x in force_alignment]:
try:
alignment_index = [x[0] for x in force_alignment].index(sql)
forced_alignment = force_alignment[alignment_index][1]
except ValueError:
forced_alignment = left
td_align = forced_alignment
else:
td_align = "left"
list_body += ('<td class=\"%s%s\" align=\"%s\">%s%s</td>' % (td_css, error_css, td_align, cell_body, error_message))
# Add item to list_result_item for list render format # Add item to list_result_item for list render format
......
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