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,9 +2291,10 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2291,9 +2291,10 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
except AttributeError: except AttributeError:
pass 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? # XXX what if the object does not have uid?
key = '%s_%s' % (editable_field.getId(), self.getUid()) key = '%s_%s' % (editable_field.getId(), self.getUid())
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 if has_error: # If there is any error on listbox, we should use what the user has typed
display_value = None display_value = None
else: else:
...@@ -2322,6 +2323,9 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2322,6 +2323,9 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
error_message = u'<br />' + error_text error_message = u'<br />' + error_text
else: else:
error_message = u'' 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 # 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 # field which is being displayed. Since the render_view API did not
......
...@@ -296,6 +296,48 @@ return [] ...@@ -296,6 +296,48 @@ return []
# Make sure that word is there # Make sure that word is there
self.assertEqual(rendered_listbox.find(word) > 0, True) 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): def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects # make sure listbox supports rendering of simple objects
# the only requirement is that objects have a `uid` attribute which is a # 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