Commit fbb5132f authored by Ivan Tyagov's avatar Ivan Tyagov

Fix a logical error which used listbox configuration to get default listbox...

Fix a logical error which used listbox configuration to get default listbox style mode. Due to historical reasons this is wrong assumption and dynamic selections of columns must use system wide constant for this. This way we can define really a default list_style for listbox. Cover this with test.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38268 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 19941fe9
...@@ -59,6 +59,8 @@ try: ...@@ -59,6 +59,8 @@ try:
except NameError: except NameError:
from sets import Set as set from sets import Set as set
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
class MethodWrapper: class MethodWrapper:
def __init__(self, context, method_name): def __init__(self, context, method_name):
self.context = context self.context = context
...@@ -409,7 +411,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -409,7 +411,7 @@ class ListBoxWidget(Widget.Widget):
title="Default display style", title="Default display style",
description=( description=(
"A default display style for listbox rendering."), "A default display style for listbox rendering."),
default='table', default=DEFAULT_LISTBOX_DISPLAY_STYLE,
required=0) required=0)
property_names.append('default_display_style') property_names.append('default_display_style')
...@@ -1146,8 +1148,7 @@ class ListBoxRenderer: ...@@ -1146,8 +1148,7 @@ class ListBoxRenderer:
default_listbox_display_style = self.getDefaultDisplayStyle() default_listbox_display_style = self.getDefaultDisplayStyle()
listbox_display_style = self.getListboxDisplayStyle() listbox_display_style = self.getListboxDisplayStyle()
dynamic_column_list_override = (self.getDisplayedColumnIdList() != None) dynamic_column_list_override = (self.getDisplayedColumnIdList() != None)
list_style_column_change_required = (default_listbox_display_style != listbox_display_style) list_style_column_change_required = listbox_display_style not in ('', DEFAULT_LISTBOX_DISPLAY_STYLE,)
if dynamic_column_list_override: if dynamic_column_list_override:
# dynamically setting columns is supported # dynamically setting columns is supported
available_column = self.getAllColumnList() available_column = self.getAllColumnList()
......
...@@ -598,6 +598,29 @@ return [] ...@@ -598,6 +598,29 @@ return []
self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle()) self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle())
self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')], self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')],
getListBoxRenderer(listbox).getSelectedColumnList()) getListBoxRenderer(listbox).getSelectedColumnList())
# set different than 'table' listbox default mode and check variations
listbox.ListBox_setPropertyList(
field_default_display_style='search',
field_style_columns=['title | thumbnail_Title',
'thumbnail | thumbnail_Thumbnail',
'getIconAsHTML | search_Icon',
'getSummaryAsHTML | search_Summary',
'B | rss_title',
'C | rss_description'],)
request.set('list_style', 'search')
self.assertEqual('search', getListBoxRenderer(listbox).getListboxDisplayStyle())
self.assertSameSet([('getIconAsHTML', 'Icon'), ('getSummaryAsHTML', 'Summary')],
getListBoxRenderer(listbox).getSelectedColumnList())
request.set('list_style', 'thumbnail')
self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle())
self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')],
getListBoxRenderer(listbox).getSelectedColumnList())
request.set('list_style', 'table')
self.assertSameSet([('id', u'ID'), ('title', u'Title'), ('getQuantity', u'Quantity')],
getListBoxRenderer(listbox).getSelectedColumnList())
def test_suite(): def test_suite():
......
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