Commit 558ddc47 authored by Ivan Tyagov's avatar Ivan Tyagov

Extend Base_getSearchText to allow it to use current listbox being rendered or...

Extend Base_getSearchText to allow it to use current listbox being rendered or directly passed arguments list.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38384 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c29346e8
...@@ -53,19 +53,26 @@ ...@@ -53,19 +53,26 @@
<value> <string>"""\n <value> <string>"""\n
Get search text from REQUEST or selection.\n Get search text from REQUEST or selection.\n
"""\n """\n
\n
request = context.REQUEST\n request = context.REQUEST\n
# get search words from listbox selection\n if not argument_name_list:\n
argument_names = (\'advanced_search_text\', \n form_id = request.get(\'form_id\', None)\n
#\'your_search_text\',\n field_id = request.get(\'field_id\', None)\n
\'title\',\n if form_id is not None and field_id is not None:\n
\'reference\',\n # get values from current ERP5 form listbox being rendered\n
\'SearchableText\',\n form = getattr(context, form_id)\n
\'searchabletext\', \n field = getattr(form, field_id)\n
\'searchabletext_any\',\n global_search_column = field.get_value(\'global_search_column\')\n
\'searchabletext_all\', \n argument_name_list = (global_search_column,)\n
\'searchabletext_phrase\',)\n else:\n
# get search words from listbox selection using hard coded default fields\n
argument_name_list = (\'advanced_search_text\', \'title\', \'reference\', \\\n
\'SearchableText\', \'searchabletext\', \\\n
\'searchabletext_any\', \'searchabletext_all\', \\\n
\'searchabletext_phrase\',)\n
\n
if selection is None:\n if selection is None:\n
selection_name = context.REQUEST.get("selection_name", None)\n selection_name = request.get("selection_name", None)\n
if selection_name is not None:\n if selection_name is not None:\n
selection = context.portal_selections.getSelectionFor(selection_name)\n selection = context.portal_selections.getSelectionFor(selection_name)\n
\n \n
...@@ -73,7 +80,7 @@ params = {}\n ...@@ -73,7 +80,7 @@ params = {}\n
if selection is not None:\n if selection is not None:\n
params = selection.getParams()\n params = selection.getParams()\n
\n \n
params = [request.get(name, params.get(name, \'\')) for name in argument_names]\n params = [request.get(name, params.get(name, \'\')) for name in argument_name_list]\n
# flatten value if it is list\n # flatten value if it is list\n
params = [(hasattr(param, \'sort\') and \' \'.join(param) or param) for param in params]\n params = [(hasattr(param, \'sort\') and \' \'.join(param) or param) for param in params]\n
search_string = \' \'.join(params).strip()\n search_string = \' \'.join(params).strip()\n
...@@ -89,7 +96,7 @@ return search_string\n ...@@ -89,7 +96,7 @@ return search_string\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>selection=None</string> </value> <value> <string>selection=None, argument_name_list=[]</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -109,18 +116,24 @@ return search_string\n ...@@ -109,18 +116,24 @@ return search_string\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>1</int> </value> <value> <int>2</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>selection</string> <string>selection</string>
<string>argument_name_list</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>request</string> <string>request</string>
<string>argument_names</string>
<string>None</string> <string>None</string>
<string>form_id</string>
<string>field_id</string>
<string>getattr</string>
<string>form</string>
<string>field</string>
<string>global_search_column</string>
<string>selection_name</string> <string>selection_name</string>
<string>params</string> <string>params</string>
<string>append</string> <string>append</string>
...@@ -143,6 +156,7 @@ return search_string\n ...@@ -143,6 +156,7 @@ return search_string\n
<value> <value>
<tuple> <tuple>
<none/> <none/>
<list/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1715 1716
\ No newline at end of file \ No newline at end of file
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