From ac5b8d5fbd2825ef53274d049ca6f4063ed7319a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 22 Dec 2018 00:19:20 +0100 Subject: [PATCH] Add support for expand, height and width attributes issue7886 review51581002 --- CHANGELOG | 1 + src/view/form.js | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 788d0f8989..6985758a24 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add support for expand, height and width attributes * Add drag & drop support on attachment button Version 5.0.0 - 2018-10-01 diff --git a/src/view/form.js b/src/view/form.js index a14aed3c24..6944c7849b 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -237,7 +237,20 @@ function eval_pyson(value){ var widget = new WidgetFactory(name, model, attributes); widget.position = this.widget_id += 1; widget.view = this; - // TODO expand, fill, height, width + if (WidgetFactory.prototype.expand) { + if (attributes.yexpand === undefined) { + attributes.yexpand = true; + } + if (attributes.yfill === undefined) { + attributes.yfill = true; + } + } + if (attributes.height) { + widget.el.css('min-height', attributes.height + 'px'); + } + if (attributes.width !== undefined) { + widget.el.css('min-width', attributes.width + 'px'); + } container.add(attributes, widget); if (this.widgets[name] === undefined) { this.widgets[name] = []; @@ -536,7 +549,9 @@ function eval_pyson(value){ return; } - // TODO yexpand + if (attributes.yexpand) { + cell.css('height', '100%'); + } if (attributes.yfill) { cell.css('vertical-align', 'top'); } @@ -1001,6 +1016,7 @@ function eval_pyson(value){ Sao.View.Form.Widget = Sao.class_(Object, { + expand: false, init: function(field_name, model, attributes) { this.field_name = field_name; this.model = model; @@ -1839,6 +1855,7 @@ function eval_pyson(value){ Sao.View.Form.Text = Sao.class_(Sao.View.Form.Widget, { class_: 'form-text', + expand: true, init: function(field_name, model, attributes) { Sao.View.Form.Text._super.init.call(this, field_name, model, attributes); @@ -1897,6 +1914,7 @@ function eval_pyson(value){ Sao.View.Form.RichText = Sao.class_(Sao.View.Form.Widget, { class_: 'form-richtext', + expand: true, init: function(field_name, model, attributes) { Sao.View.Form.RichText._super.init.call( this, field_name, model, attributes); @@ -2709,6 +2727,7 @@ function eval_pyson(value){ Sao.View.Form.One2Many = Sao.class_(Sao.View.Form.Widget, { class_: 'form-one2many', + expand: true, init: function(field_name, model, attributes) { Sao.View.Form.One2Many._super.init.call(this, field_name, model, attributes); @@ -3236,6 +3255,7 @@ function eval_pyson(value){ Sao.View.Form.Many2Many = Sao.class_(Sao.View.Form.Widget, { class_: 'form-many2many', + expand: true, init: function(field_name, model, attributes) { Sao.View.Form.Many2Many._super.init.call(this, field_name, model, attributes); @@ -3931,6 +3951,7 @@ function eval_pyson(value){ Sao.View.Form.Dict = Sao.class_(Sao.View.Form.Widget, { class_: 'form-dict', + expand: true, init: function(field_name, model, attributes) { Sao.View.Form.Dict._super.init.call( this, field_name, model, attributes);