Commit d3f94ed5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_autocompletion_ui: Clean up and make parameters names consistent with ERP5.

parent 67d35171
...@@ -50,20 +50,19 @@ ...@@ -50,20 +50,19 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>req = container.REQUEST.get\n <value> <string>kw = dict(limit=20)\n
kw = dict(limit=20)\n
\n \n
term = req("starts_with")\n if starts_with is not None and search_catalog_key is not None:\n
key = req("key")\n kw[search_catalog_key] = "%s%%" % starts_with\n
if term is not None and key is not None:\n
kw[key] = "%s%%" % term\n
\n \n
portal_type = req("portal_type")\n if search_portal_type is not None:\n
if portal_type is not None:\n kw["portal_type"] = search_portal_type\n
kw["portal_type"] = portal_type\n
\n
result = [o.title for o in context.portal_catalog(**kw)]\n
\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 \n
from json import dumps\n from json import dumps\n
return dumps(result, indent=4)\n return dumps(result, indent=4)\n
...@@ -71,7 +70,7 @@ return dumps(result, indent=4)\n ...@@ -71,7 +70,7 @@ return dumps(result, indent=4)\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -41,9 +41,10 @@ $(function() {\n ...@@ -41,9 +41,10 @@ $(function() {\n
// private\n // private\n
function generateSource(params) {\n function generateSource(params) {\n
var data = {};\n var data = {};\n
\n if (params.search_portal_type)\n
if (params.portal_type) data.portal_type = params.portal_type;\n data.search_portal_type = params.search_portal_type;\n
if (params.search_key) data.key = params.search_key;\n if (params.search_catalog_key)\n
data.search_catalog_key = params.search_catalog_key;\n
\n \n
return function(request, response) {\n return function(request, response) {\n
$.extend(data, {starts_with: request.term});\n $.extend(data, {starts_with: request.term});\n
...@@ -61,18 +62,18 @@ $(function() {\n ...@@ -61,18 +62,18 @@ $(function() {\n
\n \n
/*\n /*\n
* Wrapper around jQuery.ui.autocomplete that queries catalog\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 *\n
* Parameters:\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 * user input. For example, "title" to match titles,\n
* your_custom_reference to search for customized reference, etc\n * your_custom_reference to search for customized reference, etc\n
* - optional portal_type\n * - optional search_portal_type\n
*\n *\n
* Example:\n * Example:\n
* $(".your_input").ERP5Autocomplete({\n * $(".your_input").ERP5Autocomplete({\n
* portal_type: "Product",\n * search_portal_type: "Product",\n
* search_key: "title",\n * search_catalog_key: "title",\n
* });\n * });\n
*/\n */\n
$.fn.ERP5Autocomplete = function(kw) {\n $.fn.ERP5Autocomplete = function(kw) {\n
...@@ -80,8 +81,7 @@ $(function() {\n ...@@ -80,8 +81,7 @@ $(function() {\n
delay: 600});\n delay: 600});\n
};\n };\n
});\n });\n
</tal:block>\n </tal:block>
]]></unicode> </value> ]]></unicode> </value>
</item> </item>
......
2014-01-27 arnaud.fontaine
* Clean up and make parameters names consistent with ERP5.
2014-01-27 arnaud.fontaine 2014-01-27 arnaud.fontaine
* Increase delay before searching from 300ms (default) to 600ms, this should be enough... * Increase delay before searching from 300ms (default) to 600ms, this should be enough...
......
10 11
\ 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