From d76e8be574e4c73d3bcfc0d7802340ac253737f6 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 20 Mar 2012 12:01:15 +0100 Subject: [PATCH 1/2] [ADD] Debug layout. bzr revid: fme@openerp.com-20120320110115-1v4ypw9t06s7l9rb --- addons/web/static/src/css/base.css | 28 +++++++++++++++++++++++++++ addons/web/static/src/css/base.sass | 21 ++++++++++++++++++++ addons/web/static/src/js/view_form.js | 11 +++++++++++ addons/web/static/src/xml/base.xml | 2 +- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6b334f10c15..fac12098f17 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -347,3 +347,31 @@ width: 100%; white-space: nowrap; } +.openerp2 .oe_form_group_cell { + position: relative; +} +.openerp2 .oe_form_group_cell .oe_field_char, .openerp2 .oe_form_group_cell .oe_form_field_selection select { + width: 99%; +} +.openerp2 .oe_form_group_cell .oe_form_field_selection select { + min-width: 90px; +} +.openerp2 .oe_layout_debugging .oe_form_group { + border: 1px solid red; +} +.openerp2 .oe_layout_debugging .oe_form_group_cell { + border: 1px solid blue; +} +.openerp2 .oe_layout_debugging .oe_layout_debug_cell { + position: absolute; + color: white; + bottom: 0; + left: 0; + background: green; +} +.openerp2 .oe_layout_debugging .oe_layout_debug_cell { + display: block; +} +.openerp2 .oe_layout_debug_cell { + display: none; +} diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index fe9408c18a1..9a77d14558e 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -340,6 +340,27 @@ $colour4: #8a89ba .oe_form_button width: 100% white-space: nowrap + .oe_form_group_cell + position: relative + .oe_field_char, .oe_form_field_selection select + width: 99% + .oe_form_field_selection select + min-width: 90px + .oe_layout_debugging + .oe_form_group + border: 1px solid red + .oe_form_group_cell + border: 1px solid blue + .oe_layout_debug_cell + position: absolute + color: white + bottom: 0 + left: 0 + background: green + .oe_layout_debug_cell + display: block + .oe_layout_debug_cell + display: none // }}} .openerp diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 32660fc5c52..ec82cff76fc 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -767,6 +767,17 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({ w.replace($elem); } }); + $('').appendTo(this.$element).click(this.do_toggle_layout_debugging); + }, + do_toggle_layout_debugging: function() { + if (!this.$element.has('.oe_layout_debug_cell:first').length) { + this.$element.find('.oe_form_group_cell').each(function() { + var $span = $('').text($(this).attr('width')); + $span.prependTo($(this)); + }); + } + this.$element.toggleClass('oe_layout_debugging'); + }, process_field: function($field, $form) { var name = $field.attr('name'), diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 069f48fb48e..3f5e067285c 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -948,7 +948,7 @@ From 64f940f212f0a797a0e92fa2c9862e68e93ea5a3 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 20 Mar 2012 13:06:21 +0100 Subject: [PATCH 2/2] [FIX] Fix layouting width issue bzr revid: fme@openerp.com-20120320120621-jk4ojmz925veym1v --- addons/web/static/src/css/base.css | 1 + addons/web/static/src/css/base.sass | 1 + addons/web/static/src/js/view_form.js | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index fac12098f17..07861d4e6e8 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -361,6 +361,7 @@ } .openerp2 .oe_layout_debugging .oe_form_group_cell { border: 1px solid blue; + padding-bottom: 1em; } .openerp2 .oe_layout_debugging .oe_layout_debug_cell { position: absolute; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 9a77d14558e..746bc5d32b4 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -351,6 +351,7 @@ $colour4: #8a89ba border: 1px solid red .oe_form_group_cell border: 1px solid blue + padding-bottom: 1em .oe_layout_debug_cell position: absolute color: white diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ec82cff76fc..4f64254885e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -846,6 +846,7 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({ // Now compute width of cells $table.find('tbody > tr').each(function() { var to_compute = [], + row_cols = cols, total = 100; $(this).children().each(function() { var $td = $(this), @@ -855,13 +856,13 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({ if ($child.attr('orientation') === 'vertical') { $td.addClass('oe_vertical_separator').attr('width', '1'); $td.empty(); - cols--; + row_cols--; } break; case 'label': if ($child.attr('for')) { $td.attr('width', '1%'); - cols--; + row_cols--; total--; } break; @@ -869,7 +870,7 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({ to_compute.push($td); } }); - var unit = Math.floor(total / cols); + var unit = Math.floor(total / row_cols); _.each(to_compute, function($td, i) { var width = parseInt($td.attr('colspan'), 10) * unit; $td.attr('width', ((i == to_compute.length - 1) ? total : width) + '%');