diff --git a/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/Base_getCompletionDict.xml b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/Base_getCompletionDict.xml new file mode 100644 index 0000000000000000000000000000000000000000..8d5ec2e4ab7f7e3a295c838ebf654dbd9260fd54 --- /dev/null +++ b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/Base_getCompletionDict.xml @@ -0,0 +1,69 @@ +<?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> diff --git a/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/ERP5Site_getCompletionList.xml b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/ERP5Site_getCompletionList.xml index 34c52b805af98d429c73ba8171cd39f121f9966e..846b97ffd8d8558d85b09727014ff6f25a53cd4f 100644 --- a/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/ERP5Site_getCompletionList.xml +++ b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/ERP5Site_getCompletionList.xml @@ -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> diff --git a/bt5/erp5_autocompletion_ui/bt/change_log b/bt5/erp5_autocompletion_ui/bt/change_log index 72ad0dcedeb4da84261869fec7ba1482f00c1987..223eb6790ffd677f3498d12ec434c1d6236efa63 100644 --- a/bt5/erp5_autocompletion_ui/bt/change_log +++ b/bt5/erp5_autocompletion_ui/bt/change_log @@ -1,3 +1,6 @@ +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. diff --git a/bt5/erp5_autocompletion_ui/bt/revision b/bt5/erp5_autocompletion_ui/bt/revision index 3f10ffe7a4c473619c926cfb1e8d95e726e5a0ec..19c7bdba7b1e9bfe80365a50420a6d538ca503c3 100644 --- a/bt5/erp5_autocompletion_ui/bt/revision +++ b/bt5/erp5_autocompletion_ui/bt/revision @@ -1 +1 @@ -15 \ No newline at end of file +16 \ No newline at end of file