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 @@
</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>
......
......@@ -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>
......
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...
......
10
\ No newline at end of file
11
\ 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