Commit 88df8a25 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_autocompletion_ui: Allow customisation of object property being showed with autocompletion.

Possible through defining a TypeBasedMethod (PORTAL_TYPE_getCompletionDict)
returning a dict serialized in JSON by the calling method, or otherwise
overriding fallback script (Base_getCompletionDict).
parent 8f9d7545
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return {\'label\': obj.getTitle(),\n
\'value\': obj.getTitle(),\n
\'description\': obj.getRelativeUrl()}\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>obj</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getCompletionDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,14 +58,19 @@ if starts_with is not None and search_catalog_key is not None:\n
if search_portal_type is not None:\n
kw["portal_type"] = search_portal_type\n
\n
result = []\n
result_dict_list = []\n
for brain in context.portal_catalog(**kw):\n
result.append({\'label\': brain.getTitle(),\n
\'value\': brain.getTitle(),\n
\'description\': brain.getRelativeUrl()})\n
obj = brain.getObject()\n
\n
# There may be objects with different Portal Types, so the only way seems\n
# to call the script for each object...\n
result_dict = obj.getTypeBasedMethod(\'getCompletionDict\',\n
fallback_script_id=\'Base_getCompletionDict\')(obj)\n
\n
result_dict_list.append(result_dict)\n
\n
from json import dumps\n
return dumps(result, indent=4)\n
return dumps(result_dict_list, indent=4)\n
</string> </value>
</item>
<item>
......
2014-02-07 arnaud.fontaine
* Allow customisation of object property being showed with autocompletion.
2014-02-07 arnaud.fontaine
* Move away generic JS code from RelationField as it should be reusable anywhere.
......
13
\ No newline at end of file
14
\ 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