Commit a44ba813 authored by Kevin Deldycke's avatar Kevin Deldycke

Add support for title _and_ id on groups (see form_render and...

Add support for title _and_ id on groups (see form_render and ERP5XhtmlStyle_getFormGroupTitleAndId comments for details).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9617 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f1d6fd4a
<?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>
...@@ -87,27 +87,48 @@ XXX: each case must be handled separatelly in this precise representation :\n ...@@ -87,27 +87,48 @@ XXX: each case must be handled separatelly in this precise representation :\n
This leads to minor code duplication, but it\'s still code duplication.\n This leads to minor code duplication, but it\'s still code duplication.\n
\n \n
Breaks strict compatibility:\n Breaks strict compatibility:\n
Groups must be named one of "left", "right", "center", "bottom" otherwise they will not be rendered.\n * Groups must be named one of "left", "right", "center", "bottom" otherwise they will not\n
Group order doesn\'t matter. Case is sensitive.\n be rendered.\n
Groups names becomes "left_group", "right_group", "left1_group", "right1_group", "bottom_group" for quad_form_view macro.\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 -->\n
</tal:block>\n </tal:block>\n
\n
\n
<tal:block metal:define-macro="master">\n <tal:block metal:define-macro="master">\n
<tal:block tal:define="field_errors python: request.get(\'field_errors\',{});\n <tal:block\n
tal:define="field_errors python: request.get(\'field_errors\', {});\n
dummy python: request.set(\'here\', here);\n dummy python: request.set(\'here\', here);\n
groups python: form.get_groups(include_empty=0);">\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 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>\n
<tal:block tal:repeat="group groups">\n \n
\t <fieldset tal:attributes="class group; id python: \'fieldset_\'+group.replace(\' \', \'_\')" tal:condition="python: group.find(\'hidden\') < 0">\n <tal:block tal:repeat="group group_list">\n
<legend tal:content="group" class="group_title"/>\n <tal:block tal:define="gid python: group[0];\n
<tal:block tal:repeat="field python:form.get_fields_in_group(group)">\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 metal:use-macro="here/field_render/macros/field_render"/>\n
</tal:block>\n </tal:block>\n
</fieldset>\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 <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 </tal:block>\n
\n
</tal:block>\n </tal:block>\n
</tal:block> </tal:block>
......
2006-09-01 Kevin 2006-09-01 Kevin
* Fix hidden developper shortcuts. * 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 2006-08-31 Kevin
* Render non editable field in a span. * Render non editable field in a span.
......
154 158
\ No newline at end of file \ No newline at end of file
1.2.22 1.2.23
\ 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