diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 5bab586ff60..b0b0db61be3 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2308,6 +2308,13 @@ .openerp .oe_form .oe_form_field_text { width: 100%; } +.openerp .oe_form .oe_form_field_text .oe_form_text_content { + text-overflow: ellipsis; + display: inline-block; + white-space: pre-wrap; + overflow-x: hidden; + width: 100%; +} .openerp .oe_form .oe_form_field_char input, .openerp .oe_form .oe_form_field_url input, .openerp .oe_form .oe_form_field_email input, diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 073926b7c0a..9b8837a511d 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1832,6 +1832,12 @@ $sheet-padding: 16px .oe_form .oe_form_field_text width: 100% + .oe_form_text_content + text-overflow: ellipsis + display: inline-block + white-space: pre-wrap + overflow-x: hidden + width: 100% .oe_form_field_char input, .oe_form_field_url input, .oe_form_field_email input, diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index bf5b26d92fe..12f7d21ae4c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2559,42 +2559,43 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we }, 'change textarea': 'store_dom_value', }, - init: function (field_manager, node) { - this._super(field_manager, node); - }, initialize_content: function() { var self = this; - this.$textarea = this.$el.find('textarea'); - this.auto_sized = false; - this.default_height = this.$textarea.css('height'); - if (this.get("effective_readonly")) { - this.$textarea.attr('disabled', 'disabled'); + if (! this.get("effective_readonly")) { + this.$textarea = this.$el.find('textarea'); + this.auto_sized = false; + this.default_height = this.$textarea.css('height'); + if (this.get("effective_readonly")) { + this.$textarea.attr('disabled', 'disabled'); + } + this.setupFocus(this.$textarea); + } else { + this.$textarea = undefined; } - this.setupFocus(this.$textarea); }, commit_value: function () { this.store_dom_value(); return this._super(); }, store_dom_value: function () { - if (!this.get('effective_readonly') && this.$('textarea').length) { - this.internal_set_value( - instance.web.parse_value( - this.$textarea.val(), - this)); - } + this.internal_set_value(instance.web.parse_value(this.$textarea.val(), this)); }, render_value: function() { - var show_value = instance.web.format_value(this.get('value'), this, ''); - if (show_value === '') { - this.$textarea.css('height', parseInt(this.default_height)+"px"); - } - this.$textarea.val(show_value); - if (! this.auto_sized) { - this.auto_sized = true; - this.$textarea.autosize(); + if (! this.get("effective_readonly")) { + var show_value = instance.web.format_value(this.get('value'), this, ''); + if (show_value === '') { + this.$textarea.css('height', parseInt(this.default_height)+"px"); + } + this.$textarea.val(show_value); + if (! this.auto_sized) { + this.auto_sized = true; + this.$textarea.autosize(); + } else { + this.$textarea.trigger("autosize"); + } } else { - this.$textarea.trigger("autosize"); + var txt = this.get("value"); + this.$(".oe_form_text_content").text(txt); } }, is_syntax_valid: function() { @@ -2612,14 +2613,18 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we return this.get('value') === '' || this._super(); }, focus: function($el) { - this.$textarea[0].focus(); + if (!this.get("effective_readonly") && this.$textarea) { + this.$textarea[0].focus(); + } }, set_dimensions: function (height, width) { this._super(height, width); - this.$textarea.css({ - width: width, - minHeight: height - }); + if (!this.get("effective_readonly") && this.$textarea) { + this.$textarea.css({ + width: width, + minHeight: height + }); + } }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index f76b888a029..bd4f2f15e1f 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1032,17 +1032,22 @@
- + + + + + +