Skip to content
Permalink
Browse files

wip

  • Loading branch information...
aab-odoo committed Mar 18, 2019
1 parent 473642d commit 57cef3138c280a0f7b7ae2fad015018e271e5089
@@ -626,6 +626,19 @@ ListRenderer.include({
}
return $body;
},
/**
* Override to optionally add a th in the header for the remove icon column.
*
* @override
* @private
*/
_renderHeader: function () {
var $thead = this._super.apply(this, arguments);
if (this.addTrashIcon) {
$thead.find('tr').append($('<th>', {class: 'o_list_record_remove_header'}));
}
return $thead;
},
/**
* Editable rows are possibly extended with a trash icon on their right, to
* allow deleting the corresponding record.
@@ -191,6 +191,7 @@ var ListRenderer = BasicRenderer.extend({
_processColumns: function (columnInvisibleFields) {
var self = this;
self.handleField = null;

this.columns = _.reject(this.arch.children, function (c) {
if (c.tag === 'control') {
return true;
@@ -206,6 +207,30 @@ var ListRenderer = BasicRenderer.extend({
}
return reject;
});

this.columns.forEach(function (column) {
if (!column.attrs.colspan) {
if (column.tag !== 'field') {
column.attrs.colspan = 2;
return;
}
switch (self.state.fields[column.attrs.name].type) {
case 'text':
column.attrs.colspan = 6;
break;
case 'many2one':
case 'char':
column.attrs.colspan = 4;
break;
case 'boolean':
column.attrs.colspan = 1;
break;
default:
column.attrs.colspan = 2;
}

}
});
},
/**
* Render a list of <td>, with aggregates if available. It can be displayed
@@ -589,8 +614,15 @@ var ListRenderer = BasicRenderer.extend({
* @returns {jQueryElement} a <thead> element
*/
_renderHeader: function () {
var $tr = $('<tr>')
.append(_.map(this.columns, this._renderHeaderCell.bind(this)));
var self = this;
var totalColspan = this.columns.reduce(function (acc, column) {
return acc + column.attrs.colspan;
}, 0);
var $tr = $('<tr>').append(this.columns.map(function (column) {
var $cell = self._renderHeaderCell(column);
$cell.css('width', (column.attrs.colspan / totalColspan) + '%');
return $cell;
}));
if (this.hasSelectors) {
$tr.prepend(this._renderSelector('th'));
}
@@ -644,6 +676,8 @@ var ListRenderer = BasicRenderer.extend({
attrs: node.attrs,
};
this._addFieldTooltip(fieldDescr, $th);
} else {
$th.attr('title', description);
}
return $th;
},
@@ -697,7 +731,7 @@ var ListRenderer = BasicRenderer.extend({
if (disableInput) {
$content.find("input[type='checkbox']").prop('disabled', disableInput);
}
return $('<' + tag + ' width="1">')
return $('<' + tag + '>')
.addClass('o_list_record_selector')
.append($content);
},
@@ -1,5 +1,6 @@

.o_list_view {
table-layout: fixed;
position: relative;
cursor: pointer;
background-color: $o-view-background-color;
@@ -23,9 +24,7 @@
border-bottom: 1px solid #cacaca;
> tr > th {
border-left: 1px solid #dfdfdf;
@include media-breakpoint-down(sm) {
white-space: nowrap;
}
@include o-text-overflow(table-cell);
&:not(.o_column_sortable):hover {
cursor: default;
}
@@ -41,6 +40,13 @@
border-bottom: 1px solid #cacaca;
}

.o_list_record_selector {
width: 40px;
}
.o_list_record_remove_header {
width: 30px;
}

.o_column_sortable {
position: relative;
user-select: none; // Prevent unwanted selection while sorting
@@ -76,9 +82,9 @@
}
}

.o_list_record_selector, .o_list_record_remove, .o_handle_cell {
width: 1px; // to prevent the column to expand
}
// .o_list_record_selector, .o_list_record_remove, .o_handle_cell {
// width: 1px; // to prevent the column to expand
// }

.o_list_record_remove button {
padding: 0px;

0 comments on commit 57cef31

Please sign in to comment.
You can’t perform that action at this time.