Commit 9370d8d9 authored by Aurel's avatar Aurel

in search dialog, only display fields which are defined searchable in

the listbox


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21768 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9929501b
...@@ -212,50 +212,54 @@ def getSearchDialog(self, REQUEST=None): ...@@ -212,50 +212,54 @@ def getSearchDialog(self, REQUEST=None):
column_list = ListBoxListRenderer( column_list = ListBoxListRenderer(
listbox.widget, listbox, request).getAllColumnList() listbox.widget, listbox, request).getAllColumnList()
search_list = [x[0] for x in ListBoxListRenderer(
listbox.widget, listbox, request).getSearchValueList()]
for column_id, column_title in column_list: for column_id, column_title in column_list:
# is it a base category ? if column_id in search_list:
short_column_id = column_id # is it a base category ?
# strip the usuale default_ and _title that are on standard fields. short_column_id = column_id
if short_column_id.endswith('_title'): # strip the usuale default_ and _title that are on standard fields.
short_column_id = short_column_id[:-6] if short_column_id.endswith('_title'):
if short_column_id.startswith('default_'): short_column_id = short_column_id[:-6]
short_column_id = short_column_id[8:] if short_column_id.startswith('default_'):
if short_column_id in base_category_list: short_column_id = short_column_id[8:]
# is this base category empty ? then it might be used to relate documents, if short_column_id in base_category_list:
# in that case, simply provide a text input # is this base category empty ? then it might be used to relate documents,
if not len(category_tool[short_column_id]): # in that case, simply provide a text input
default_search_key = 'ExactMatch' if not len(category_tool[short_column_id]):
if column_id in sql_catalog_keyword_search_keys:
default_search_key = 'Keyword'
addKeywordSearchStringField(column_id, column_title,
default_search_key=default_search_key)
else:
addListField(short_column_id, column_title)
continue
if column_id in catalog_schema:
if column_id.endswith('state') or column_id.endswith('state_title'):
# this is a workflow state, it will be handled later
continue
elif 'date' in column_id:
# is it date ? -> provide exact + range
# TODO: do we need an API in catalog for this ?
addDateTimeField(column_id, column_title)
elif 'quantity' in column_id or 'price' in column_id:
# is it float ? -> provide exact + range
# TODO: do we need an API in catalog for this ?
addFloatField(column_id, column_title)
else:
if column_id in sql_catalog_full_text_search_keys:
addFullTextStringField(column_id, column_title)
else:
default_search_key = 'ExactMatch' default_search_key = 'ExactMatch'
if column_id in sql_catalog_keyword_search_keys: if column_id in sql_catalog_keyword_search_keys:
default_search_key = 'Keyword' default_search_key = 'Keyword'
addKeywordSearchStringField(column_id, column_title, addKeywordSearchStringField(column_id, column_title,
default_search_key=default_search_key) default_search_key=default_search_key)
else:
addListField(short_column_id, column_title)
continue
if column_id in catalog_schema:
if column_id.endswith('state') or column_id.endswith('state_title'):
# this is a workflow state, it will be handled later
continue
elif 'date' in column_id:
# is it date ? -> provide exact + range
# TODO: do we need an API in catalog for this ?
addDateTimeField(column_id, column_title)
elif 'quantity' in column_id or 'price' in column_id:
# is it float ? -> provide exact + range
# TODO: do we need an API in catalog for this ?
addFloatField(column_id, column_title)
else:
if column_id in sql_catalog_full_text_search_keys:
addFullTextStringField(column_id, column_title)
else:
default_search_key = 'ExactMatch'
if column_id in sql_catalog_keyword_search_keys:
default_search_key = 'Keyword'
addKeywordSearchStringField(column_id, column_title,
default_search_key=default_search_key)
# TODO always add SearchableText ? # TODO always add SearchableText ?
......
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