From bcb86755c0f9de70e227ec5014792c213882d78e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 29 May 2012 17:10:55 +0200 Subject: [PATCH] [FIX] Fix trunk-fp bzr revid: fme@openerp.com-20120529151055-gc098pdvfvyh3dep --- addons/web/static/src/css/base.css | 3 - addons/web/static/src/css/base.sass | 2 - addons/web/static/src/js/view_form.js | 133 +++++++++++++------------- addons/web/static/src/xml/base.xml | 20 +--- 4 files changed, 66 insertions(+), 92 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6eeeac715d6..d956cc1c39f 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1591,9 +1591,6 @@ .openerp .oe_form .oe_form_group_cell > div > .oe_datepicker_root > input.oe_datepicker_master { width: 100%; } -.openerp .oe_form .oe_form_group_cell.oe_form_group_nested { - padding: 0; -} .openerp .oe_form .oe_form_label_help[for], .openerp .oe_form .oe_form_label[for] { font-weight: bold; white-space: nowrap; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index e8e5b36bce8..7ff1af4743d 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1286,8 +1286,6 @@ $colour4: #8a89ba .oe_form_group_cell > div > .oe_datepicker_root, .oe_form_group_cell > div > .oe_datepicker_root > input.oe_datepicker_master width: 100% - .oe_form_group_cell.oe_form_group_nested - padding: 0 // }}} // FormView.label {{{ .oe_form diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c8f53e7fd50..f20f6bf1781 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1061,34 +1061,31 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt return $label; }, process_field: function($field, layout) { - // Note FP: No implicit labels for normal fields, only for children - // var $label = this.preprocess_field($field); - // if ($label) - // this.process($label, layout); + if ($field.parent().is('group')) { + // No implicit labels for normal fields, only for direct children + var $label = this.preprocess_field($field); + if ($label) { + this.process($label, layout); + } + } this.fields_to_init.push($field); return $field; }, process_group: function($group, layout) { var self = this; - // Note FP: not clean to do such a hack, commenting it - // if ($group.parent().is('.oe_form_group_cell')) { - // $group.parent().addClass('oe_form_group_nested'); - // } - $group.children('field').each(function() { self.preprocess_field($(this)); }); - var $new_group = this.render_element('FormRenderingGroup', layout, $group.getAttributes()), - $table; - if ($new_group.is('table')) { + var $new_group = this.render_element('FormRenderingGroup', layout, $group.getAttributes()); + var $table; + if ($new_group.first().is('table.oe_form_group')) { $table = $new_group; + } else if ($new_group.filter('table.oe_form_group').length) { + $table = $new_group.filter('table.oe_form_group').first(); } else { - $table = $new_group.find('table:first'); + $table = $new_group.find('table.oe_form_group').first(); } - // Note FP: why don't we put that in the QWeb template ? - $table.addClass('oe_form_group'); - var $tr, $td, cols = parseInt($group.attr('col') || 4, 10), row_cols = cols; @@ -1101,7 +1098,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var $td = $('').addClass('oe_form_group_cell').attr('colspan', colspan); var newline = tagName === 'newline'; - // Note FP: looks like a hack to avoid + // Note FME: those classes are used in layout debug mode if ($tr && row_cols > 0 && (newline || row_cols < colspan)) { $tr.addClass('oe_form_group_row_incomplete'); if (newline) { @@ -1131,59 +1128,57 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } $group.before($new_group).remove(); - // Now compute width of cells - // Note FP: It would be better to remove this, using width="50%" rather than colspan="2" - // $table.find('> tbody > tr').each(function() { - // var to_compute = [], - // row_cols = cols, - // total = 100; - // $(this).children().each(function() { - // var $td = $(this), - // $child = $td.children(':first'); - // switch ($child[0].tagName.toLowerCase()) { - // case 'separator': - // if ($child.attr('orientation') === 'vertical') { - // $td.addClass('oe_vertical_separator').attr('width', '1'); - // $td.empty(); - // row_cols--; - // } - // break; - // case 'label': - // if ($child.attr('for')) { - // $td.attr('width', '1%').addClass('oe_form_group_cell_label'); - // row_cols--; - // total--; - // } - // break; - // default: - // var width = _.str.trim($child.attr('width') || ''), - // iwidth = parseInt(width, 10); - // if (iwidth) { - // if (width.substr(-1) === '%') { - // total -= iwidth; - // width = iwidth + '%'; - // } else { - // // Absolute width - // $td.css('min-width', width + 'px'); - // } - // $td.attr('width', width); - // $child.removeAttr('width'); - // row_cols--; - // } else { - // to_compute.push($td); - // } + $table.find('> tbody > tr').each(function() { + var to_compute = [], + row_cols = cols, + total = 100; + $(this).children().each(function() { + var $td = $(this), + $child = $td.children(':first'); + switch ($child[0].tagName.toLowerCase()) { + case 'separator': + if ($child.attr('orientation') === 'vertical') { + $td.addClass('oe_vertical_separator').attr('width', '1'); + $td.empty(); + row_cols--; + } + break; + case 'label': + if ($child.attr('for')) { + $td.attr('width', '1%').addClass('oe_form_group_cell_label'); + row_cols--; + total--; + } + break; + default: + var width = _.str.trim($child.attr('width') || ''), + iwidth = parseInt(width, 10); + if (iwidth) { + if (width.substr(-1) === '%') { + total -= iwidth; + width = iwidth + '%'; + } else { + // Absolute width + $td.css('min-width', width + 'px'); + } + $td.attr('width', width); + $child.removeAttr('width'); + row_cols--; + } else { + to_compute.push($td); + } - // } - // }); - // var unit = Math.floor(total / row_cols); - // if (!$(this).is('.oe_form_group_row_incomplete')) { - // _.each(to_compute, function($td, i) { - // var width = parseInt($td.attr('colspan'), 10) * unit; - // $td.attr('width', ((i == to_compute.length - 1) ? total : width) + '%'); - // total -= width; - // }); - // } - // }); + } + }); + var unit = Math.floor(total / row_cols); + if (!$(this).is('.oe_form_group_row_incomplete')) { + _.each(to_compute, function($td, i) { + var width = parseInt($td.attr('colspan'), 10) * unit; + $td.attr('width', ((i == to_compute.length - 1) ? total : width) + '%'); + total -= width; + }); + } + }); _.each(children, function(el) { self.process($(el)); }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 9c628982301..56f7c379c65 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -786,10 +786,8 @@ - - - - + +
@@ -1066,20 +1064,6 @@
- -
- -
    - - -
  • - -
  • -
    -
-
-
-