[Erp5-report] r9617 - in /erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style: SkinTemplate...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Sep 1 18:03:38 CEST 2006


Author: kevin
Date: Fri Sep  1 18:03:34 2006
New Revision: 9617

URL: http://svn.erp5.org?rev=9617&view=rev
Log:
Add support for title _and_ id on groups (see form_render and ERP5XhtmlStyle_getFormGroupTitleAndId comments for details).

Added:
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_getFormGroupTitleAndId.xml
Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/form_render.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/change_log
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/version

Added: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_getFormGroupTitleAndId.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_getFormGroupTitleAndId.xml?rev=9617&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_getFormGroupTitleAndId.xml (added)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_getFormGroupTitleAndId.xml Fri Sep  1 18:03:34 2006
@@ -1,0 +1,212 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </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>"""\n
+  This script split a form group id in two part:\n
+    * a group id,\n
+    * a group title.\n
+\n
+  The group should be named based on the following pattern: "group id (Group Title)" \n
+\n
+  This script is a hack to let us merge two informations (id and title) into one (id) to get\n
+    over Formulator limitations. This script should disappear with Formulator\'s refactoring.\n
+\n
+  Features: \n
+    * Multiple parenthesis allowed;\n
+    * Group id can continue after the title definition.\n
+\n
+  Example:\n
+    A string like\n
+      "left webcontent (The Fantastic Group (and (funky) lisp-like parenthesis)) extra",\n
+    will return the following tuple:\n
+      ( \'left webcontent extra\'\n
+      , \'The Fantastic Group (and (funky) lisp-like parenthesis)\'\n
+      , \'left webcontent (The Fantastic Group (and (funky) lisp-like parenthesis)) extra\'\n
+      )\n
+"""\n
+\n
+if not same_type(original_group_id, \'string\'):\n
+  return None\n
+\n
+# Separate the group id and the group title using parenthesis as marker from the original form group id\n
+o_gid_list = original_group_id.strip().split(\'(\')\n
+\n
+# Get the first part of the group id (which is the part before the first opened parenthesis)\n
+group_id = o_gid_list[0]\n
+\n
+# Get the end of the list (which is the part just after the first opened parenthesis)\n
+group_title_list = \'(\'.join(o_gid_list[1:]).split(\')\')\n
+\n
+# Get the last part of the group id (the part which stand after the last closing parenthesis)\n
+group_id += group_title_list[-1]\n
+\n
+# Normalize the group id (suppress unecessary multiple-space)\n
+group_id_list = []\n
+for group_word in group_id.split(\' \'):\n
+  if len(group_word):\n
+    group_id_list.append(group_word)\n
+group_id = \' \'.join(group_id_list)\n
+\n
+# Generate the group title\n
+group_title = \')\'.join(group_title_list[:-1]).strip()\n
+\n
+# Return the group id if no title found\n
+if len(group_title) == 0:\n
+  group_title = group_id\n
+\n
+return ( group_id\n
+       , group_title\n
+       , original_group_id\n
+       )\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>original_group_id=None</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>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>original_group_id</string>
+                            <string>same_type</string>
+                            <string>None</string>
+                            <string>_getattr_</string>
+                            <string>o_gid_list</string>
+                            <string>_getitem_</string>
+                            <string>group_id</string>
+                            <string>group_title_list</string>
+                            <string>group_id_list</string>
+                            <string>_getiter_</string>
+                            <string>group_word</string>
+                            <string>len</string>
+                            <string>group_title</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <none/>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5XhtmlStyle_getFormGroupTitleAndId</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/form_render.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/form_render.xml?rev=9617&r1=9616&r2=9617&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/form_render.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/form_render.xml Fri Sep  1 18:03:34 2006
@@ -61,7 +61,7 @@
 <!--\n
 Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.\n
                    Vincent Pelletier <vincent at nexedi.com>\n
-                   Christophe Dumez <christophe at nexedi.com>\n
+                   Christophe Dumez  <christophe at nexedi.com>\n
 \n
 This program is Free Software; you can redistribute it and/or\n
 modify it under the terms of the GNU General Public License\n
@@ -87,27 +87,48 @@
 This leads to minor code duplication, but it\'s still code duplication.\n
 \n
 Breaks strict compatibility:\n
-Groups must be named one of "left", "right", "center", "bottom" otherwise they will not be rendered.\n
-Group order doesn\'t matter. Case is sensitive.\n
-Groups names becomes "left_group", "right_group", "left1_group", "right1_group", "bottom_group" for quad_form_view macro.\n
+  * Groups must be named one of "left", "right", "center", "bottom" otherwise they will not\n
+      be rendered.\n
+  * Group order doesn\'t matter. Case is sensitive.\n
+  * Groups names becomes "left_group", "right_group", "left1_group", "right1_group",\n
+      "bottom_group" for quad_form_view macro.\n
+\n
+It is possible to specify a group id and a group title by naming a group following the\n
+  "group id (Group Title)" pattern. In this case the group id will be used as fieldset css\n
+  class and as tag id. The group title will be used as a legend for the fieldset. If no group\n
+  title is found, we use group id as title.\n
 -->\n
 </tal:block>\n
+\n
+\n
 <tal:block metal:define-macro="master">\n
-  <tal:block tal:define="field_errors python: request.get(\'field_errors\',{});\n
-                         dummy python: request.set(\'here\', here);\n
-                         groups python: form.get_groups(include_empty=0);">\n
+  <tal:block\n
+    tal:define="field_errors python: request.get(\'field_errors\', {});\n
+                dummy        python: request.set(\'here\', here);\n
+                group_list   python: [];\n
+                dummy        python: group_list.extend([here.ERP5XhtmlStyle_getFormGroupTitleAndId(x) for x in form.get_groups(include_empty=0)]);\n
+                gid_list     python: \' \'.join([x[0] for x in group_list]);">\n
+\n
     <tal:block tal:define="template python: here.developper_shortcut_render">\n
-      <tal:block metal:use-macro="template/macros/form" />\n
+      <tal:block metal:use-macro="template/macros/form"/>\n
     </tal:block>\n
-    <tal:block tal:repeat="group groups">\n
-\t    <fieldset tal:attributes="class group; id python: \'fieldset_\'+group.replace(\' \', \'_\')" tal:condition="python: group.find(\'hidden\') < 0">\n
-        <legend tal:content="group" class="group_title"/>\n
-        <tal:block tal:repeat="field python:form.get_fields_in_group(group)">\n
-          <tal:block metal:use-macro="here/field_render/macros/field_render"/>\n
-        </tal:block>\n
-      </fieldset>\n
-      <p tal:condition="python: group.find(\'right\') >= 0 or (group.find(\'left\') >= 0 and \'right\' not in groups)" class="clear"></p>\n
+\n
+    <tal:block tal:repeat="group group_list">\n
+      <tal:block tal:define="gid     python: group[0];\n
+                             gtitle  python: group[1];\n
+                             goid    python: group[2];">\n
+        <fieldset tal:condition="python: gid.find(\'hidden\') < 0"\n
+          tal:attributes="class python: gid;\n
+                          id    python: \'fieldset_\' + gid.replace(\' \', \'_\');">\n
+          <legend tal:content="python: gtitle" class="group_title"/>\n
+          <tal:block tal:repeat="field python: form.get_fields_in_group(goid)">\n
+            <tal:block metal:use-macro="here/field_render/macros/field_render"/>\n
+          </tal:block>\n
+        </fieldset>\n
+        <p tal:condition="python: gid.find(\'right\') >= 0 or (gid.find(\'left\') >= 0 and \'right\' not in gid_list)" class="clear"/>\n
+      </tal:block>\n
     </tal:block>\n
+\n
   </tal:block>\n
 </tal:block>
 

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/change_log
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/change_log?rev=9617&r1=9616&r2=9617&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/change_log (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/change_log Fri Sep  1 18:03:34 2006
@@ -1,5 +1,6 @@
 2006-09-01 Kevin
 * Fix hidden developper shortcuts.
+* Add support for title _and_ id on groups (see form_render and ERP5XhtmlStyle_getFormGroupTitleAndId comments for details).
 
 2006-08-31 Kevin
 * Render non editable field in a span.

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision?rev=9617&r1=9616&r2=9617&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision Fri Sep  1 18:03:34 2006
@@ -1,1 +1,1 @@
-154
+158

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/version
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/version?rev=9617&r1=9616&r2=9617&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/version (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/version Fri Sep  1 18:03:34 2006
@@ -1,1 +1,1 @@
-1.2.22
+1.2.23




More information about the Erp5-report mailing list