diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 80eab3faebe8e5f1acc723995a056e215dbd093c..e028dd14e645effbe4e509f3ef8d7c274ead9585 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -59,6 +59,8 @@ try: except NameError: from sets import Set as set +DEFAULT_LISTBOX_DISPLAY_STYLE = 'table' + class MethodWrapper: def __init__(self, context, method_name): self.context = context @@ -409,7 +411,7 @@ class ListBoxWidget(Widget.Widget): title="Default display style", description=( "A default display style for listbox rendering."), - default='table', + default=DEFAULT_LISTBOX_DISPLAY_STYLE, required=0) property_names.append('default_display_style') @@ -1146,8 +1148,7 @@ class ListBoxRenderer: default_listbox_display_style = self.getDefaultDisplayStyle() listbox_display_style = self.getListboxDisplayStyle() 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: # dynamically setting columns is supported available_column = self.getAllColumnList() diff --git a/product/ERP5Form/tests/testListBox.py b/product/ERP5Form/tests/testListBox.py index f44a26384ab72615588e7bc3086f4898866ff60c..4c18a817820094bf84264b13218e5d71faf0dc11 100644 --- a/product/ERP5Form/tests/testListBox.py +++ b/product/ERP5Form/tests/testListBox.py @@ -598,6 +598,29 @@ return [] self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle()) self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')], 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():