From 81ffa759442f10387a306aa85367a237e07c7fb3 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 7 Jul 2015 10:34:18 +0200 Subject: [PATCH] [FIX] web: many2manytags: hidden if empty and readonly In edit mode, if this field is readonly and empty, its main div has height 0 but its border is displayed. This rev. simply hides the field in this case. --- addons/web/static/src/js/views/form_common.js | 12 +++++++++++- .../static/src/less/enterprise_compatibility.less | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/form_common.js b/addons/web/static/src/js/views/form_common.js index cd6d061919f..19737746b4a 100644 --- a/addons/web/static/src/js/views/form_common.js +++ b/addons/web/static/src/js/views/form_common.js @@ -692,10 +692,20 @@ var AbstractField = FormWidget.extend(FieldInterface, { start: function() { this._super(); this.on("change:value", this, function() { - if (! this.no_rerender) + if (!this.no_rerender) { this.render_value(); + } + this._toggle_label(); + }); + this.on("change:effective_readonly", this, function() { + this._toggle_label(); }); this.render_value(); + this._toggle_label(); + }, + _toggle_label: function() { + var empty = this.get('effective_readonly') && this.is_false(); + this.$el.toggleClass('o_form_field_empty', empty); }, /** * Private. Do not use. diff --git a/addons/web/static/src/less/enterprise_compatibility.less b/addons/web/static/src/less/enterprise_compatibility.less index bab17780958..8d97c3b74d3 100644 --- a/addons/web/static/src/less/enterprise_compatibility.less +++ b/addons/web/static/src/less/enterprise_compatibility.less @@ -247,6 +247,10 @@ border: 1px solid #CCC; border-radius: 3px; + &.o_form_field_empty { + display: none; + } + > .oe_form_field { .o-flex(1, 0, 100px);