Commit 0bc89eb8 authored by Jérome Perrin's avatar Jérome Perrin

Use ERP5Form/Extensions/Folder_viewSearchDialog to have a contextual generic...

Use ERP5Form/Extensions/Folder_viewSearchDialog to have a contextual generic search dialog based on listbox configuration and allowed content types instead or the old not-so-usefull dialog. Folder_search is now used as search action.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17715 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5fae0455
......@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -68,9 +65,67 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>REQUEST=context.REQUEST\n
return getattr(context,form_id)(REQUEST)\n
</string> </value>
<value> <string encoding="cdata"><![CDATA[
request = container.REQUEST\n
\n
def sorted(seq):\n
seq = [x for x in seq]\n
seq.sort()\n
return seq\n
\n
# Convert mapping from request.form into something the catalog can understand\n
# This script uses ad-hoc values that are understood by\n
# Folder_viewSearchDialog: x_value_ and x_usage_ are used to remember what was\n
# the entered value, and what was the usage.\n
\n
# Note that we don\'t use queries, because we want to let the catalog filter out\n
# ignored parameters by itself.\n
\n
usage_map = dict(min=\'>=\',\n
max=\'<\',\n
ngt=\'<=\',\n
nlt=\'>\',)\n
\n
new_mapping = dict()\n
for key in sorted(request.form.keys()):\n
# we use sorted to make sure x_search_key appears before x\n
value = request.form[key]\n
\n
# workaround the bogus case where a value is passed ?value=None\n
if value == \'None\':\n
value = None\n
\n
# remove Formulator markers\n
if key.startswith(\'default_\') or key.startswith(\'field_\'):\n
request.form.pop(key)\n
continue\n
\n
if key.endswith(\'_search_key\') and value:\n
real_key = key[:-11]\n
new_mapping[real_key] = dict(query=new_mapping[real_key], key=value)\n
\n
elif key.endswith(\'_usage_\') and value:\n
request.form.pop(key)\n
real_key = key[:-7]\n
new_mapping[\'%s_value_\' % real_key] = new_mapping[real_key]\n
new_mapping[\'%s_usage_\' % real_key] = value\n
# TODO: this is a quick and dirty implementation of what should be done by\n
# Query.asSearchTextExpression. Instead of keeping \'%s_value_\' and \'%s_usage_\',\n
# we\'ll simply keep the query.\n
new_mapping[real_key] = \'%s %s\' % (usage_map[value], new_mapping[real_key])\n
\n
else:\n
new_mapping[key] = value\n
\n
# set selection parameters\n
container.portal_selections.setSelectionParamsFor(selection_name, new_mapping)\n
\n
request.form.update(new_mapping)\n
return getattr(context, form_id)(request)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -86,7 +141,7 @@ return getattr(context,form_id)(REQUEST)\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'\'</string> </value>
<value> <string>form_id=\'\', selection_name=\'\', **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -106,17 +161,31 @@ return getattr(context,form_id)(REQUEST)\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>form_id</string>
<string>selection_name</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>REQUEST</string>
<string>container</string>
<string>request</string>
<string>sorted</string>
<string>dict</string>
<string>usage_map</string>
<string>new_mapping</string>
<string>_getiter_</string>
<string>key</string>
<string>_getitem_</string>
<string>value</string>
<string>None</string>
<string>real_key</string>
<string>_write_</string>
<string>getattr</string>
<string>context</string>
</tuple>
</value>
</item>
......@@ -130,6 +199,7 @@ return getattr(context,form_id)(REQUEST)\n
<value>
<tuple>
<string></string>
<string></string>
</tuple>
</value>
</item>
......@@ -139,7 +209,7 @@ return getattr(context,form_id)(REQUEST)\n
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Paste objects to a folder from the clipboard</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -19,111 +16,25 @@
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_searchHandler</string> </value>
<key> <string>_function</string> </key>
<value> <string>getSearchDialog</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
<key> <string>_module</string> </key>
<value> <string>ERP5Form.Folder_viewSearchDialog</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<key> <string>_owner</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_list_form_id</string>
<string>your_description</string>
<string>your_id</string>
<string>your_title</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Folder_viewSearchDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Folder_viewSearchDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Search</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
......
579
\ No newline at end of file
580
\ 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