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 69c202ed3994020703a9293143693329c875294f..5d7a76be171ce942b7bde215ea961992978a947b 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 @@ -50,20 +50,19 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>req = container.REQUEST.get\n -kw = dict(limit=20)\n + <value> <string>kw = dict(limit=20)\n \n -term = req("starts_with")\n -key = req("key")\n -if term is not None and key is not None:\n - kw[key] = "%s%%" % term\n +if starts_with is not None and search_catalog_key is not None:\n + kw[search_catalog_key] = "%s%%" % starts_with\n \n -portal_type = req("portal_type")\n -if portal_type is not None:\n - kw["portal_type"] = portal_type\n -\n -result = [o.title for o in context.portal_catalog(**kw)]\n +if search_portal_type is not None:\n + kw["portal_type"] = search_portal_type\n \n +result = []\n +for brain in context.portal_catalog(**kw):\n + result.append({\'label\': brain.getTitle(),\n + \'value\': brain.getTitle(),\n + \'description\': brain.getRelativeUrl()})\n \n from json import dumps\n return dumps(result, indent=4)\n @@ -71,7 +70,7 @@ return dumps(result, indent=4)\n </item> <item> <key> <string>_params</string> </key> - <value> <string></string> </value> + <value> <string>starts_with=None, search_catalog_key=None, search_portal_type=None</string> </value> </item> <item> <key> <string>id</string> </key> diff --git a/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/jquery.erp5.autocompletion.js.xml b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/jquery.erp5.autocompletion.js.xml index accd97b066888eacb4317b7c78796f331ea36d18..a7d858019c62dd1b4ae2eb514f7a3e8af41d65fe 100644 --- a/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/jquery.erp5.autocompletion.js.xml +++ b/bt5/erp5_autocompletion_ui/SkinTemplateItem/portal_skins/erp5_autocompletion_ui/jquery.erp5.autocompletion.js.xml @@ -41,9 +41,10 @@ $(function() {\n // private\n function generateSource(params) {\n var data = {};\n -\n - if (params.portal_type) data.portal_type = params.portal_type;\n - if (params.search_key) data.key = params.search_key;\n + if (params.search_portal_type)\n + data.search_portal_type = params.search_portal_type;\n + if (params.search_catalog_key)\n + data.search_catalog_key = params.search_catalog_key;\n \n return function(request, response) {\n $.extend(data, {starts_with: request.term});\n @@ -61,18 +62,18 @@ $(function() {\n \n /*\n * Wrapper around jQuery.ui.autocomplete that queries catalog\n - * to return matching terms. Titles are displayed.\n + * to return matching terms. Display title by default.\n *\n * Parameters:\n - * - search_key: catalog key that should be matched against\n + * - search_catalog_key: catalog key that should be matched against\n * user input. For example, "title" to match titles,\n * your_custom_reference to search for customized reference, etc\n - * - optional portal_type\n + * - optional search_portal_type\n *\n * Example:\n * $(".your_input").ERP5Autocomplete({\n - * portal_type: "Product",\n - * search_key: "title",\n + * search_portal_type: "Product",\n + * search_catalog_key: "title",\n * });\n */\n $.fn.ERP5Autocomplete = function(kw) {\n @@ -80,8 +81,7 @@ $(function() {\n delay: 600});\n };\n });\n -</tal:block>\n - +</tal:block> ]]></unicode> </value> </item> diff --git a/bt5/erp5_autocompletion_ui/bt/change_log b/bt5/erp5_autocompletion_ui/bt/change_log index fdf07b240eca6c2abfc8937bb10054561ebfa934..853ed030908449033d05fbd6163fb893b6df74a9 100644 --- a/bt5/erp5_autocompletion_ui/bt/change_log +++ b/bt5/erp5_autocompletion_ui/bt/change_log @@ -1,3 +1,6 @@ +2014-01-27 arnaud.fontaine +* Clean up and make parameters names consistent with ERP5. + 2014-01-27 arnaud.fontaine * Increase delay before searching from 300ms (default) to 600ms, this should be enough... diff --git a/bt5/erp5_autocompletion_ui/bt/revision b/bt5/erp5_autocompletion_ui/bt/revision index 9a037142aa3c1b4c490e1a38251620f113465330..9d607966b721abde8931ddd052181fae905db503 100644 --- a/bt5/erp5_autocompletion_ui/bt/revision +++ b/bt5/erp5_autocompletion_ui/bt/revision @@ -1 +1 @@ -10 \ No newline at end of file +11 \ No newline at end of file