Commit b4ee3766 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Render Extra and CSS fields in Listbox lines


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33620 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6040cc4c
......@@ -2291,37 +2291,41 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
except AttributeError:
pass
if editable_field is not None and sql in editable_column_id_set:
if editable_field is not None:
# XXX what if the object does not have uid?
key = '%s_%s' % (editable_field.getId(), self.getUid())
if has_error: # If there is any error on listbox, we should use what the user has typed
display_value = None
else:
validated_value_dict = request.get(field_id, None)
if validated_value_dict is None:
# If this is neither an error nor a validated listbox
# we should use the original value
display_value = original_value
if sql in editable_column_id_set:
if has_error: # If there is any error on listbox, we should use what the user has typed
display_value = None
else:
# If the listbox has been validated (ie. as it is the
# case whenever a relation field displays a popup menu)
# we have to use the value entered by the user
display_value = None #
if error_dict.has_key(key): # If error on current field, we should display message
error_text = error_dict[key].error_text
error_text = cgi.escape(error_text)
if isinstance(error_text, str):
error_mapping = getattr(error_dict[key], 'error_mapping', None)
if error_mapping is not None:
error_text = u'%s' % Message(domain=ui_domain,
message=error_text,
mapping=error_mapping)
validated_value_dict = request.get(field_id, None)
if validated_value_dict is None:
# If this is neither an error nor a validated listbox
# we should use the original value
display_value = original_value
else:
error_text = u'%s' % Message(domain=ui_domain,
message=error_text)
error_message = u'<br />' + error_text
# If the listbox has been validated (ie. as it is the
# case whenever a relation field displays a popup menu)
# we have to use the value entered by the user
display_value = None #
if error_dict.has_key(key): # If error on current field, we should display message
error_text = error_dict[key].error_text
error_text = cgi.escape(error_text)
if isinstance(error_text, str):
error_mapping = getattr(error_dict[key], 'error_mapping', None)
if error_mapping is not None:
error_text = u'%s' % Message(domain=ui_domain,
message=error_text,
mapping=error_mapping)
else:
error_text = u'%s' % Message(domain=ui_domain,
message=error_text)
error_message = u'<br />' + error_text
else:
error_message = u''
else:
error_message = u''
display_value = original_value
# We need a way to pass the current line object (ie. brain) to the
# field which is being displayed. Since the render_view API did not
......
......@@ -296,6 +296,48 @@ return []
# Make sure that word is there
self.assertEqual(rendered_listbox.find(word) > 0, True)
def test_07_ExtraAndCssFieldsInIntegerField(self, quiet=0, run=run_all_test):
"""
Check that css_class and extra fields are rendered when used in a
listbox_xxx line, using IntegerField for the check.
"""
portal = self.getPortal()
portal.ListBoxZuite_reset()
# Reset listbox properties
listbox = portal.FooModule_viewFooList.listbox
listbox.ListBox_setPropertyList(
field_list_method = 'portal_catalog',
field_columns = ['extra | Check extra',],
)
form = portal.FooModule_viewFooList
form.manage_addField('listbox_extra', 'extra', 'IntegerField')
integerfield = form.listbox_extra
word = 'dummy_%s_to_check_for_in_listbox_test'
extra = word % "extra"
css_class = word % "css_class"
integerfield.values['extra'] = "alt='%s'" % extra
integerfield.values['css_class'] = css_class
integerfield.values['default'] = '42'
# Create an new empty object with a list property
foo_module = portal.foo_module
o = foo_module.newContent()
# Reindex
o.immediateReindexObject()
# Render the module in html
request = get_request()
request['here'] = portal.foo_module
rendered_listbox = listbox.render(REQUEST=request)
# Make sure that the extras and css_classes
self.assertTrue(extra in rendered_listbox)
self.assertTrue(css_class in rendered_listbox)
def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects
# the only requirement is that objects have a `uid` attribute which is a
......
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