Commit a7c5fdf6 authored by Nicolas Dumazet's avatar Nicolas Dumazet

There's no precedence for listbox cell configuration. It's a boolean AND:

isEditable(listbox "field" cell) <=>
   isEditable(listbox_field) AND ("field" in listbox.editable_columns)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33704 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5ec219c
...@@ -2330,18 +2330,19 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2330,18 +2330,19 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
display_value = original_value display_value = original_value
enabled = editable_field.get_value('enabled', REQUEST=request) enabled = editable_field.get_value('enabled', REQUEST=request)
editable = editable_field.get_value('editable', REQUEST=request)
if enabled: if enabled:
# 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
# permit this, we use the 'cell' value to pass the line object. # permit this, we use the 'cell' value to pass the line object.
request.set('cell', brain) request.set('cell', brain)
# Listbox 'editable' configuration should take precedence over # Field is editable only if listbox lists it in editable columns AND
# individual field configuration # if listbox_field is editable
cell_html = editable_field.render( cell_html = editable_field.render(
value=display_value, value=display_value,
REQUEST=request, REQUEST=request,
key=key, key=key,
editable=listbox_defines_column_as_editable, editable=listbox_defines_column_as_editable and editable,
) )
if isinstance(cell_html, str): if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding) cell_html = unicode(cell_html, encoding)
...@@ -2351,7 +2352,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2351,7 +2352,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
if url is None: if url is None:
html = cell_html + error_message html = cell_html + error_message
else: else:
if editable_field.get_value('editable', REQUEST=request): if editable:
html = u'%s' % cell_html html = u'%s' % cell_html
else: else:
html = u'<a href="%s">%s</a>' % (url, cell_html) html = u'<a href="%s">%s</a>' % (url, cell_html)
......
...@@ -378,34 +378,49 @@ return [] ...@@ -378,34 +378,49 @@ return []
self._helperExtraAndCssInListboxLine("LinesField", True) self._helperExtraAndCssInListboxLine("LinesField", True)
self._helperExtraAndCssInListboxLine("LinesField", False) self._helperExtraAndCssInListboxLine("LinesField", False)
def test_09_editablePropertyPrecedence(self): def test_09_editablePropertyConfiguration(self):
""" """
When listbox's editable column and listbox_xx's editable property Test editable behavior of delegated columns.
conflict, the listbox editable column choice should take over. A column is editable if and only if listbox_foo is editable AND foo is
in the editable columns of the listbox.
For example, if listbox_foo is defined as editable, without For example, if listbox_foo is defined as editable, without
having column "foo" listed as editable in the listbox, the field should having column "foo" listed as editable in the listbox, the field should
not be rendered as editable not be rendered as editable
""" """
self._helperEditableColumn(True, True, True)
self._helperEditableColumn(False, False, False)
self._helperEditableColumn(True, False, False)
self._helperEditableColumn(False, True, False)
def _helperEditableColumn(self, editable_in_listbox, editable_in_line,
expected_editable):
portal = self.getPortal() portal = self.getPortal()
portal.ListBoxZuite_reset() portal.ListBoxZuite_reset()
field_name = 'noneditable' field_name = 'editableproperty_%s_%s' \
field_id = 'listbox_noneditable' % (editable_in_listbox, editable_in_line)
field_name = field_name.lower()
field_id = 'listbox_%s' % field_name
# Reset listbox properties # Reset listbox properties
listbox = portal.FooModule_viewFooList.listbox listbox = portal.FooModule_viewFooList.listbox
listbox.ListBox_setPropertyList( kw = dict(
field_list_method = 'portal_catalog', field_list_method = 'portal_catalog',
field_columns = ['%s | Check extra' % field_name,], field_columns = ['%s | Check extra' % field_name,],
) )
if editable_in_listbox:
kw['field_editable_columns'] = '%s | Check extra' % field_name
listbox.ListBox_setPropertyList(**kw)
form = portal.FooModule_viewFooList form = portal.FooModule_viewFooList
form.manage_addField(field_id, field_name, "StringField") form.manage_addField(field_id, field_name, "StringField")
field = getattr(form, field_id) field = getattr(form, field_id)
field.values['default'] = '42' field.values['default'] = '42'
field.values['editable'] = True field.values['editable'] = editable_in_line
form.groups['bottom'].remove(field_id) form.groups['bottom'].remove(field_id)
form.groups['hidden'].append(field_id) form.groups['hidden'].append(field_id)
...@@ -428,7 +443,10 @@ return [] ...@@ -428,7 +443,10 @@ return []
'//input[starts-with(@name, $name)]', '//input[starts-with(@name, $name)]',
name='field_%s_' % field_id, name='field_%s_' % field_id,
) )
self.assertEquals(len(editable_field_list), 0)
msg = "editable_in_listbox: %s, editable_in_line: %s" \
% (editable_in_listbox, editable_in_line)
self.assertEquals(len(editable_field_list) == 1, expected_editable, msg)
def test_ObjectSupport(self): def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects # make sure listbox supports rendering of simple objects
......
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