Commit 63b88e67 authored by Vincent Pelletier's avatar Vincent Pelletier

Improve FormBox integration.

Allows FormBox to contain fields outside "left" group.
The use of this is most evident when FormBox is in the "bottom" group: it
allows included form to have field groups with borders (left, right,
center) or without borders (bottom), hence allowing competely extending
base form. This required rewriting JS code stitching "left" & "right"
groups together so it honours nesting.
For backward compatibility, hide "left" groups rendered inside any bordered
group - but only when there is no field in "right" group.
Also, clean up duplicated code in embedded_form_render and use proper
naming (templates used by forms should always end with "_view").
parent 7bd4e4af
......@@ -86,6 +86,7 @@ function autoFocus() {\n
function buildTables(element_list, rowPredicate, columnPredicate,\n
tableClassName) {\n
/* Generic code to build a table from elements in element_list.\n
* XXX: not used anymore ?\n
* rowPredicate(element) -> bool\n
* When it returns a true value, a new line is started with element.\n
* When is returns a false value, element is skipped.\n
......@@ -146,11 +147,13 @@ function buildTables(element_list, rowPredicate, columnPredicate,\n
}\n
\n
function matchLeftFieldset(element) {\n
// XXX: not used anymore ?\n
return (element.tagName == "FIELDSET" &&\n
element.className.toLowerCase().indexOf(\'left\') != -1)\n
}\n
\n
function matchRightFieldset(element, ignored) {\n
// XXX: not used anymore ?\n
if (element.tagName == "FIELDSET" &&\n
element.className.toLowerCase().indexOf(\'right\') != -1)\n
return 7; /* End row, table and use element */\n
......@@ -159,9 +162,25 @@ function matchRightFieldset(element, ignored) {\n
\n
function fixLeftRightHeightAndFocus(fix_height) {\n
if (fix_height == 1) {\n
buildTables(document.getElementsByTagName(\'fieldset\'),\n
matchLeftFieldset, matchRightFieldset,\n
"fake");\n
var right_xpath = "following-sibling::fieldset[contains(@class, \'right\')]";\n
var matched_left_element_list = document.evaluate("//fieldset[contains(@class, \'left\') and " + right_xpath + "]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);\n
var element_index;\n
for (element_index = 0; element_index < matched_left_element_list.snapshotLength; element_index++) {\n
var element = matched_left_element_list.snapshotItem(element_index);\n
var right = document.evaluate(right_xpath, element, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\n
var cell;\n
var row = document.createElement("tr");\n
var table = document.createElement("table");\n
table.className = "fake";\n
element.parentNode.insertBefore(table, element);\n
cell = document.createElement("td");\n
cell.appendChild(element);\n
row.appendChild(cell);\n
cell = document.createElement("td");\n
cell.appendChild(right);\n
row.appendChild(cell);\n
table.appendChild(row);\n
}\n
}\n
autoFocus();\n
}\n
......
......@@ -53,73 +53,7 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block tal:replace="nothing"\n
xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal"\n
xmlns:i18n="http://xml.zope.org/namespaces/i18n">\n
<!--\n
Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.\n
Vincent Pelletier <vincent@nexedi.com>\n
Christophe Dumez <christophe@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
as published by the Free Software Foundation; either version 2\n
of the License, or (at your option) any later version.\n
\n
This program is distributed in the hope that it will be useful,\n
but WITHOUT ANY WARRANTY; without even the implied warranty of\n
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n
GNU General Public License for more details.\n
\n
You should have received a copy of the GNU General Public License\n
along with this program; if not, write to the Free Software\n
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
\n
XXX: each case must be handled separatelly in this precise representation :\n
- both top fields must be in the same div, so they must be identified\n
strictly by their name.\n
- the middle field is rendered like the two top ones, but outside of the\n
top block.\n
- the bottom block is rendered in another way (without its group name) so it\n
must be rendered separatelly.\n
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\n
be rendered.\n
* Group order doesn\'t matter. Case is sensitive.\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
<tal:block metal:define-macro="master">\n
<tal:block\n
tal:define="field_errors python: request.get(\'field_errors\', {});\n
preferred_html_style_developper_mode python: 0;\n
preferred_html_style_translator_mode python: 0;\n
dummy python: request.set(\'here\', here);\n
group_list python: form.Form_getGroupTitleAndId();\n
gid_list python: \' \'.join([x[\'gid\'] for x in group_list if x!=\'hidden\']);\n
field_render nocall: here/field_render/macros/field_render">\n
\n
<tal:block tal:repeat="group group_list">\n
<tal:block tal:define="gid group/gid;">\n
<tal:block tal:condition="python: gid.find(\'hidden\') < 0">\n
<tal:block tal:repeat="field python: form.get_fields_in_group(group[\'goid\'])">\n
<tal:block metal:use-macro="field_render"/>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
<p class="clear"></p>\n
</tal:block>\n
</tal:block>\n
<tal:block metal:use-macro="here/embedded_form_view/macros/master" />
]]></unicode> </value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</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>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>description</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>text</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal"\n
xmlns:i18n="http://xml.zope.org/namespaces/i18n">\n
<tal:block metal:define-macro="master">\n
<tal:block metal:use-macro="here/global_definitions/macros/header_definitions" />\n
<tal:block metal:use-macro="here/form_render/macros/master" />\n
</tal:block>\n
</tal:block>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>blash</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>embedded_form_view</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -711,7 +711,12 @@ fieldset.right {\n
margin-left: -12px; /* 5px margin *2 + 2px for left & right border width */\n
}\n
\n
table.fake fieldset {\n
/* BBB: don\'t display borders on left-group fieldsets in a formbox in any\n
* bordered fieldset (ie left, right or center). */\n
fieldset.left fieldset.left,\n
fieldset.right fieldset.left,\n
fieldset.center fieldset.left,\n
table.fake > tr > td > fieldset {\n
border-width: 0;\n
padding: 0;\n
margin: 0;\n
......@@ -728,7 +733,7 @@ fieldset.bottom {\n
border-width: 0;\n
}\n
\n
fieldset.bottom .field label {\n
fieldset.bottom > .field > label {\n
display: none;\n
}\n
\n
......
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