summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2019-08-09 08:07:55 +0000
committerAaron Bohy <aab@odoo.com>2019-08-23 06:28:34 +0000
commitbf3c1d3e0c2cb9f6ed560994d24de026c080aa01 (patch)
treec0f38a904ad368b62276d519d53fbc9aee48811e /addons/web/static/src/js/fields
parent43ad74798fd971e2c514b67a0f706b8e65165843 (diff)
[IMP] web: editable list: column's widths
This rev. refines the way we compute column's widths in editable list views. When there are displayed records, we let the browser compute the width of each column (which is thus optimal with respect to the content), and we then freeze those widths s.t. it doesn't flicker when we switch a row in edition. When there is no record, we keep the former heuristic based on absolute and relative widths (depending on field types). However, we set the same weight for all fields having a relative width (i.e. all but boolean, date(time) and numeric), such that the remaining space is evenly distributed between them. Co-authored-by: Aaron Bohy <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js30
1 files changed, 28 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index fcae2043d00..eefb771c69a 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -17,10 +17,11 @@ var AbstractField = require('web.AbstractField');
var basicFields = require('web.basic_fields');
var concurrency = require('web.concurrency');
var ControlPanelView = require('web.ControlPanelView');
-var dialogs = require('web.view_dialogs');
var core = require('web.core');
var data = require('web.data');
var Dialog = require('web.Dialog');
+var dialogs = require('web.view_dialogs');
+var dom = require('web.dom');
var KanbanRecord = require('web.KanbanRecord');
var KanbanRenderer = require('web.KanbanRenderer');
var ListRenderer = require('web.ListRenderer');
@@ -905,6 +906,22 @@ var FieldX2Many = AbstractField.extend({
start: function () {
return this._renderControlPanel().then(this._super.bind(this));
},
+ /**
+ * For the list renderer to properly work, it must know if it is in the DOM,
+ * and be notified when it is attached to the DOM.
+ */
+ on_attach_callback: function () {
+ this.isInDOM = true;
+ if (this.renderer) {
+ this.renderer.on_attach_callback();
+ }
+ },
+ /**
+ * For the list renderer to properly work, it must know if it is in the DOM.
+ */
+ on_detach_callback: function () {
+ this.isInDOM = false;
+ },
//--------------------------------------------------------------------------
// Public
@@ -1096,7 +1113,16 @@ var FieldX2Many = AbstractField.extend({
this.renderer = new Renderer(this, this.value, rendererParams);
this.$el.addClass('o_field_x2many o_field_x2many_' + viewType);
- return this.renderer ? this.renderer.appendTo(this.$el) : this._super();
+ if (this.renderer) {
+ return this.renderer.appendTo(document.createDocumentFragment()).then(function () {
+ dom.append(self.$el, self.renderer.$el, {
+ in_DOM: self.isInDOM,
+ callbacks: [{widget: self.renderer}],
+ });
+ });
+ } else {
+ return this._super();
+ }
},
/**
* Instanciates a control panel with the appropriate buttons and a pager.