From 9d7d7f668b1c169dd731f7fd72bcaf4a83f04b5e Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 28 May 2012 19:21:14 +0200 Subject: [PATCH 1/9] [IMP] improved CSS, XML bzr revid: fp@openerp.com-20120528172114-dc950hkrmn9wthnd --- addons/web/static/src/css/base.css | 11 ++- addons/web/static/src/css/base.sass | 9 +- addons/web/static/src/js/view_form.js | 126 ++++++++++++++------------ addons/web/static/src/xml/base.xml | 121 +++++++++++-------------- 4 files changed, 133 insertions(+), 134 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 89b8cc1a38f..6eeeac715d6 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1607,6 +1607,11 @@ top: -4px; padding: 0 2px; } +.openerp .oe_form h2 input { + font-size: 20px; + font-weight: bold; + height: 30px; +} .openerp .oe_form textarea { resize: vertical; } @@ -1767,6 +1772,7 @@ .openerp .oe_form .oe-binary-file-set { overflow: hidden; position: relative; + display: inline-block; width: 45px; height: 30px; } @@ -1895,11 +1901,6 @@ .openerp .oe-select-create-popup-view-form > .oe_formview > .oe_form_pager { display: none; } -.openerp .oe_form .oe_form_title, .openerp .oe_form .oe_form_title input { - font-size: 20px; - font-weight: bold; - height: 30px; -} .openerp .oe_form .oe_form_group_odd_border > tbody > tr.oe_form_group_row > td.oe_form_group_cell:nth-child(odd), .openerp .oe_form .oe_form_group_label_border > tbody > tr.oe_form_group_row > td.oe_form_group_cell_label { border-right: 1px solid #dddddd; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index e013009f9b1..e8e5b36bce8 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1305,6 +1305,10 @@ $colour4: #8a89ba // }}} // FormView.fields {{{ .oe_form + h2 input + font-size: 20px + font-weight: bold + height: 30px textarea resize: vertical input[type="text"], @@ -1448,6 +1452,7 @@ $colour4: #8a89ba .oe-binary-file-set overflow: hidden position: relative + display: inline-block width: 45px height: 30px input.oe-binary-file @@ -1567,10 +1572,6 @@ $colour4: #8a89ba // }}} // FormView.classes for openerp views {{{ .oe_form - .oe_form_title, .oe_form_title input - font-size: 20px - font-weight: bold - height: 30px .oe_form_group_odd_border > tbody > tr.oe_form_group_row > td.oe_form_group_cell:nth-child(odd), .oe_form_group_label_border > tbody > tr.oe_form_group_row > td.oe_form_group_cell_label border-right: 1px solid #ddd diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 22f2a1c23a4..c8f53e7fd50 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1023,6 +1023,11 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } this.process($new_form, layout); }, + /* + * Used by direct children of a tag only + * This method will add the implicit for every field + * in the + */ preprocess_field: function($field) { var self = this; var name = $field.attr('name'), @@ -1056,17 +1061,20 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt return $label; }, process_field: function($field, layout) { - var $label = this.preprocess_field($field); - if ($label) - this.process($label, layout); + // Note FP: No implicit labels for normal fields, only for 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; - if ($group.parent().is('.oe_form_group_cell')) { - $group.parent().addClass('oe_form_group_nested'); - } + // 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)); }); @@ -1077,7 +1085,10 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } else { $table = $new_group.find('table: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; @@ -1089,6 +1100,8 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var tagName = $child[0].tagName.toLowerCase(); var $td = $('').addClass('oe_form_group_cell').attr('colspan', colspan); var newline = tagName === 'newline'; + + // Note FP: looks like a hack to avoid if ($tr && row_cols > 0 && (newline || row_cols < colspan)) { $tr.addClass('oe_form_group_row_incomplete'); if (newline) { @@ -1119,57 +1132,58 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt $group.before($new_group).remove(); // 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), - $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); - } + // 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); + // } - } - }); - 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 b1101fb09d2..9c628982301 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -786,18 +786,10 @@ - - - -
- - -
-
- - + +
@@ -1075,70 +1067,61 @@
-
    - - -
  • - -
  • -
    -
+
+ +
    + + +
  • + +
  • +
    +
+
+
-
    - - -
  • - - -
  • -
    -
+
+
    + + +
  • + + +
  • +
    +
+
+
-
- - - - -
- -
-
- - - - - -
-
-
- - - - -
-
-
- -
+
+
+
+
+
+ + + + +
- -