Commit 65b9e097 authored by Ivan Tyagov's avatar Ivan Tyagov

Add new checkbox property on listbox field which if enabled can omit showing...

Add new checkbox property on listbox field which if enabled can omit showing listbox rows if no input (i.e. search criterions) are provided by user.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28179 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f2e19ee6
......@@ -312,6 +312,14 @@ class ListBoxWidget(Widget.Widget):
required=0)
property_names.append('anchor')
hide_rows_on_no_search_criterion = \
fields.CheckBoxField('hide_rows_on_no_search_criterion', \
title = 'Hide Rows (On No Search Criterion)', \
description = ('Hide listbox rows if no search criterion is provided by user'), \
default = 0, \
required = 0)
property_names.append('hide_rows_on_no_search_criterion')
editable_columns = fields.ListTextAreaField('editable_columns',
title="Editable Columns",
description=(
......@@ -667,6 +675,32 @@ class ListBoxRenderer:
showAnchorColumn = lazyMethod(showAnchorColumn)
def isHideRowsOnNoSearchCriterion(self, REQUEST={}):
"""
Return a boolean that represents whether search rows are shown or not.
"""
hide_rows_on_no_search_criterion = \
self.field.get_value('hide_rows_on_no_search_criterion')
if not hide_rows_on_no_search_criterion:
# we show all rows and do not care to hide anything
return 0
# we could hide rows only if missing in request or selection search criterions
selection_params = self.getSelection().getParams()
listbox_searchable_column_id_list = [x[0] for x in self.getSearchValueList() \
if x[0] is not None]
for listbox_searchable_column_id in listbox_searchable_column_id_list:
search_criterion = REQUEST.get(listbox_searchable_column_id, \
selection_params.get(listbox_searchable_column_id, None))
if search_criterion not in (None, "",) and not isinstance(search_criterion, dict):
# search criterion is usually input by user by UI, ignore created automated
# by listbox_xxx form fields selection parameters as they do not represent
# user input but rather a developer formating definition in form
return 0
return 1
hideRowsMissingSearchCriterion = lazyMethod(isHideRowsOnNoSearchCriterion)
def showStat(self):
"""Return a boolean that represents whether a stat line is displayed or not.
......
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