Improve responsive table behaviour

- Hide invisible columns
- Use all width for label and value
- Make header follow style if editable
- Center checkboxes

issue6107
review25901002
This commit is contained in:
Cédric Krier committed 2016-12-22 11:08:46 +01:00
1 parent 4b780e4f20
commit cedd9d1153
2 files changed
+44 -23

No files matched your search

+28 -19
View File
@@ -1,4 +1,5 @@
@import "variables";
@import "mixins";
.navbar {
z-index: @zindex-navbar;
@@ -118,9 +119,9 @@ button {
.form {
width: 100%;
& > .form-container {
& > table.form-container {
width: 100%;
& td {
& > tbody > tr > td {
padding: 1px;
}
}
@@ -206,6 +207,9 @@ button {
.column-integer, .column-float, .column-timedelta {
text-align: right;
}
input.column-boolean, input.selection {
.center-block();
}
.form-boolean, .editabletree-boolean {
& input[type=checkbox] {
@@ -249,10 +253,10 @@ button {
table.responsive,
table.responsive > thead,
table.responsive > thead > tr,
table.responsive > thead > tr > th,
table.responsive > thead > tr > th:not(.invisible),
table.responsive > tbody,
table.responsive > tbody > tr,
table.responsive > tbody > tr > td {
table.responsive > tbody > tr > td:not(.invisible) {
display: block !important;
}
table.responsive {
@@ -285,22 +289,27 @@ button {
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 30%;
}
& > tbody > tr > td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 30%;
padding-right: 10px;
text-align: left;
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
/* Label */
content: attr(data-title);
& > tbody > tr {
& > td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
padding-right: 10px;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
/* Label */
content: attr(data-title);
}
& > td.required:before {
font-weight: bold;
}
& > td.editable:before {
font-style: italic;
}
}
}
}
+16 -4
View File
@@ -316,10 +316,10 @@
if (!name) {
return;
}
if (decoder.decode(column.attributes.tree_invisible || '0')) {
column.header.hide();
} else if (name === this.screen.exclude_field) {
if ((decoder.decode(column.attributes.tree_invisible || '0')) ||
(name === this.screen.exclude_field)) {
column.header.hide();
column.header.addClass('invisible');
} else {
var inv_domain = inversion.domain_inversion(domain, name);
if (typeof inv_domain != 'boolean') {
@@ -328,8 +328,10 @@
var unique = inversion.unique_value(inv_domain)[0];
if (unique && jQuery.isEmptyObject(this.children_field)) {
column.header.hide();
column.header.addClass('invisible');
} else {
column.header.show();
column.header.removeClass('invisible');
}
}
}.bind(this));
@@ -656,7 +658,8 @@
for (var i = 0; i < this.tree.columns.length; i++) {
var column = this.tree.columns[i];
td = jQuery('<td/>', {
'data-title': column.attributes.string
// TODO RTL
'data-title': column.attributes.string + Sao.i18n.gettext(': ')
}).append(jQuery('<div/>', { // For responsive min-height
'aria-hidden': true
}));
@@ -666,6 +669,13 @@
true));
if (!this.tree.editable) {
td.dblclick(this.switch_row.bind(this));
} else {
if (column.attributes.required) {
td.addClass('required');
}
if (!column.attributes.readonly) {
td.addClass('editable');
}
}
var widgets = this.build_widgets();
var table = widgets[0];
@@ -789,8 +799,10 @@
if ((column.header.is(':hidden') && thead_visible) ||
column.header.css('display') == 'none') {
td.hide();
td.addClass('invisible');
} else {
td.show();
td.removeClass('invisible');
}
}
var row_id_path = this.get_id_path();