[Erp5-report] r37465 nicolas.dumazet - in /erp5/trunk/bt5/erp5_jquery: SkinTemplateItem/por...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Aug 4 08:20:40 CEST 2010
Author: nicolas.dumazet
Date: Wed Aug 4 08:20:38 2010
New Revision: 37465
URL: http://svn.erp5.org?rev=37465&view=rev
Log:
Generic jQuery extension to provide autocompletion on fields.
ERP5Site_getCompletionList serves as a backend for jQuery, and
polls the catalog. getCompletionList should be extensible and quite
flexible, even if it only supports portal_type and one key filtering for
now.
Most common usage should be something like:
$("input.custom_class_defined_in_field").ERP5Autocomplete({
portal_type: "Product",
search_key: "title",
});
( produces catalog(portal_type="Product", title="xy%", limit=20) )
but any catalog parameter can used as a key, which means that
$("input.custom_class_defined_in_field").ERP5Autocomplete({
portal_type: "Product",
search_key: "xxcustomer_product_reference",
});
will work if xxcustomer_product_reference is a custom catalog key
Added:
erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/ERP5Site_getCompletionList.xml
erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/jquery.erp5.js.xml
Modified:
erp5/trunk/bt5/erp5_jquery/bt/revision
Added: erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/ERP5Site_getCompletionList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/ERP5Site_getCompletionList.xml?rev=37465&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/ERP5Site_getCompletionList.xml (added)
+++ erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/ERP5Site_getCompletionList.xml [utf8] Wed Aug 4 08:20:38 2010
@@ -0,0 +1,155 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+ <tuple/>
+ </tuple>
+ </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>req = container.REQUEST.get\n
+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
+\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
+\n
+\n
+from Products.ERP5Type.JSON import dumps\n
+return dumps(result, indent=4)\n
+</string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string></string> </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>0</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>_getattr_</string>
+ <string>container</string>
+ <string>req</string>
+ <string>dict</string>
+ <string>kw</string>
+ <string>term</string>
+ <string>key</string>
+ <string>None</string>
+ <string>_write_</string>
+ <string>portal_type</string>
+ <string>append</string>
+ <string>$append0</string>
+ <string>_getiter_</string>
+ <string>_apply_</string>
+ <string>context</string>
+ <string>o</string>
+ <string>result</string>
+ <string>Products.ERP5Type.JSON</string>
+ <string>dumps</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>ERP5Site_getCompletionList</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Added: erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/jquery.erp5.js.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/jquery.erp5.js.xml?rev=37465&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/jquery.erp5.js.xml (added)
+++ erp5/trunk/bt5/erp5_jquery/SkinTemplateItem/portal_skins/erp5_jquery/jquery.erp5.js.xml [utf8] Wed Aug 4 08:20:38 2010
@@ -0,0 +1,106 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+ <tuple/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <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_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>_text</string> </key>
+ <value> <string encoding="cdata"><![CDATA[
+
+<tal:block tal:define="update_path python: container.ERP5Site_getCompletionList.absolute_url()">\n
+$(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
+\n
+ return function(request, response) {\n
+ $.extend(data, {starts_with: request.term});\n
+ $.ajax({\n
+ url: "<tal:block tal:replace="update_path" />",\n
+ dataType: "json",\n
+ data: data,\n
+ success: response,\n
+ });\n
+ };\n
+ }\n
+\n
+ /*\n
+ * Wrapper around jQuery.ui.autocomplete that queries catalog\n
+ * to return matching terms. Titles are displayed.\n
+ *\n
+ * Parameters:\n
+ * - search_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
+ *\n
+ * Example:\n
+ * $(".your_input").ERP5Autocomplete({\n
+ * portal_type: "Product",\n
+ * search_key: "title",\n
+ * });\n
+ */\n
+ $.fn.ERP5Autocomplete = function(kw) {\n
+ return this.autocomplete({source: generateSource(kw)});\n
+ };\n
+});\n
+</tal:block>\n
+
+
+]]></string> </value>
+ </item>
+ <item>
+ <key> <string>content_type</string> </key>
+ <value> <string>text/html</string> </value>
+ </item>
+ <item>
+ <key> <string>expand</string> </key>
+ <value> <int>0</int> </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>jquery.erp5.js</string> </value>
+ </item>
+ <item>
+ <key> <string>title</string> </key>
+ <value> <string>Wrappers and helpers for ERP5</string> </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: erp5/trunk/bt5/erp5_jquery/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_jquery/bt/revision?rev=37465&r1=37464&r2=37465&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_jquery/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_jquery/bt/revision [utf8] Wed Aug 4 08:20:38 2010
@@ -1 +1 @@
-10
\ No newline at end of file
+11
\ No newline at end of file
More information about the Erp5-report
mailing list