[FIX] web: visible studio hooks in listview

Before this commit, there are no hooks when dragging a field over an
editable listview. This was caused by wrong computation of column
width in studio mode.

This commit isolate the computation of column width, so that studio
can override it and make the correct computation.

Task-Id 2057829

closes odoo/odoo#36959

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
This commit is contained in:
Priyanka Kakadiya
2019-09-25 14:43:55 +00:00
committed by Alexandre Kühn
co-authored by Mohammed Shekha
parent 458355405f
commit c536b369d3
@@ -640,6 +640,18 @@ ListRenderer.include({
}
return $borderDataRow;
},
/**
* Compute the sum of the weights for each columns, excluding
* those with an absolute width. param `$thread` is useful for studio, in
* order to show column hooks.
*
* @private
* @param {jQuery} $thead
* @return {integer}
*/
_getColumnsTotalWidth($thead) {
return this.columns.reduce((acc, column) => acc + (column.attrs.relativeWidth || 0), 0);
},
/**
* Returns the width of a column according the 'width' attribute set in the
* arch, the widget or the field type. A fixed width is harcoded for some
@@ -1053,11 +1065,7 @@ ListRenderer.include({
if (!this.columnWidths) {
if (!this._hasVisibleRecords(this.state)) {
// we compute the sum of the weights for each columns, excluding
// those with an absolute width.
var totalWidth = this.columns.reduce(function (acc, column) {
return acc + (column.attrs.relativeWidth || 0);
}, 0);
var totalWidth = this._getColumnsTotalWidth($thead);
this.columns.forEach(function (column) {
let width;
if (column.attrs.absoluteWidth) {