From 66ea5439741704346a45441b009240797628636f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 27 Oct 2011 14:43:25 +0200 Subject: [PATCH] [FIX] Add support for @align attribute in form views lp bug: https://launchpad.net/bugs/844625 fixed bzr revid: fme@openerp.com-20111027124325-ckd8kuujbb591nqu --- addons/web/static/src/css/base.css | 13 ++++++++++++- addons/web/static/src/js/view_form.js | 13 +++++++++++-- addons/web/static/src/xml/base.xml | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e8f1ff9c3bb..ae73607aab0 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -874,7 +874,6 @@ label.error { } .openerp .oe_forms label.oe_label, .openerp .oe_forms label.oe_label_help { - text-align: right; margin: 3px 0 0 10px; } .openerp label.oe_label_help span { @@ -885,6 +884,18 @@ label.error { top: -4px; padding: 0 2px; } +.openerp .oe_align_left { + text-align: left; +} +.openerp .oe_align_right { + text-align: right; +} +.openerp .oe_align_center { + text-align: center; +} +.openerp .oe_forms .oe_form_paragraph { + margin: 3px 0 0 0; +} /* Inputs */ .openerp .oe_forms input[type="text"], .openerp .oe_forms input[type="password"], .openerp .oe_forms select, .openerp .oe_forms textarea { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b864365df99..6f499a0adf7 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -717,6 +717,16 @@ openerp.web.form.Widget = openerp.web.Widget.extend(/** @lends openerp.web.form. this.invisible = this.modifiers['invisible'] === true; this.classname = 'oe_form_' + this.type; + this.align = parseFloat(this.node.attrs.align); + if (isNaN(this.align) || this.align === 1) { + this.align = 'right'; + } else if (this.align === 0) { + this.align = 'left'; + } else { + this.align = 'center'; + } + + this.width = this.node.attrs.width; }, start: function() { @@ -1046,8 +1056,7 @@ openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({ this._super(view, node); - // TODO fme: support for attrs.align - if (this.node.tag == 'label' && (this.node.attrs.colspan || (this.string && this.string.length > 32))) { + if (this.node.tag == 'label' && (this.align === 'left' || this.node.attrs.colspan || (this.string && this.string.length > 32))) { this.template = "WidgetParagraph"; this.colspan = parseInt(this.node.attrs.colspan || 1, 10); } else { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index dbee68fdb83..8984daffeb3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -752,7 +752,7 @@ -

+