From 9fffae335893fa37c1a0e7618124c1fec866fcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 22 Mar 2018 21:49:46 +0100 Subject: [PATCH] Ensure consistent treeview rendering by using fixed table-layout - always use fixed table-layout - define col for each column with a relative width - add title to content and header of cells in case of overflow - remove padding when editing cell - remove padding and margin on button in treeview issue7245 review37111002 --- src/sao.js | 9 ++++-- src/sao.less | 27 ++++++++++++---- src/tab.js | 3 -- src/view.js | 25 -------------- src/view/form.js | 7 ++-- src/view/tree.js | 84 ++++++++++++++++++++++++++++++++---------------- src/wizard.js | 3 -- 7 files changed, 86 insertions(+), 72 deletions(-) diff --git a/src/sao.js b/src/sao.js index 4e3844b1e9..b08a91ed0c 100644 --- a/src/sao.js +++ b/src/sao.js @@ -454,8 +454,10 @@ var Sao = {}; jQuery('#menu').append(gs.el); jQuery('#menu').append( form.screen.screen_container.content_box.detach()); - form.screen.views[0].columns.push( - new FavoriteColumn(form.screen.model.fields.favorite)); + var column = new FavoriteColumn(form.screen.model.fields.favorite); + form.screen.views[0].table.find('> colgroup').append(column.col); + form.screen.views[0].table.find('> thead > tr').append(column.header); + form.screen.views[0].columns.push(column); }); }; Sao.main_menu_screen = null; @@ -463,6 +465,9 @@ var Sao = {}; var FavoriteColumn = Sao.class_(Object, { init: function(favorite) { this.field = favorite; + this.col = jQuery('', { + 'class': 'favorite', + }); this.header = jQuery(''); this.footers = []; this.attributes = jQuery.extend({}, this.field.description); diff --git a/src/sao.less b/src/sao.less index 44dc6e300e..aab74aaa9d 100644 --- a/src/sao.less +++ b/src/sao.less @@ -83,12 +83,16 @@ img.icon { & > table.tree { width: 100%; + table-layout: fixed; - & th.selection, td.selection { + & col.selection-state, col.favorite { + width: 30px; + } + + & th.selection-state, td.selection-state { & > input { .center-block(); } - width: 30px; } & > thead > tr > th { & > label.sortable { @@ -96,7 +100,6 @@ img.icon { } overflow: hidden; text-overflow: ellipsis; - min-width: 30px; text-align: center; &.char, &.text, &.many2one, &.one2one, &.date, &.time, &.selection, &.reference, &.url, &.email, &.callto, &.sip { @@ -134,6 +137,13 @@ img.icon { & td { white-space: nowrap; text-overflow: ellipsis; + overflow: hidden; + } + & td.edited { + /* We have to define an overflow:visible in order for the + completion widget to be shown */ + overflow: visible; + padding: 0 0; } & td > .column-text { white-space: pre; @@ -151,6 +161,13 @@ img.icon { & label.editable { font-style: italic; } + + & .btn { + padding-top: 0; + padding-bottom: 0; + margin-top: -@table-condensed-cell-padding; + margin-bottom: -@table-condensed-cell-padding; + } } .form { @@ -315,10 +332,6 @@ input.column-boolean { } @media screen and (max-width: @screen-xs-max) { - .treeview.responsive { - /* Override the width from Sao.View.resize */ - width: 100% !important; - } table.responsive, table.responsive > thead, table.responsive > thead > tr, diff --git a/src/tab.js b/src/tab.js index 7c8eb2bb13..ae317e2d00 100644 --- a/src/tab.js +++ b/src/tab.js @@ -380,9 +380,6 @@ id: tab.id }).html(tab.el) .appendTo(tabcontent); - tab_link.on('shown.bs.tab', function() { - Sao.View.resize(tab.el); - }); tab_link.tab('show'); tabs.trigger('ready'); }; diff --git a/src/view.js b/src/view.js index f9ce1cb6c2..d0791e24dd 100644 --- a/src/view.js +++ b/src/view.js @@ -61,29 +61,4 @@ return new Sao.View.Calendar(screen, xml); } }; - - Sao.View.resize = function(el) { - // Let the browser compute the table size with the fixed layout - // then set this size to the treeview to allow scroll on overflow - // and set the table layout to auto to get the width from the content. - if (!el) { - el = jQuery(document); - } - el.find('.treeview').each(function() { - var treeview = jQuery(this); - treeview.css('width', '100%'); - treeview.children('.tree').css('table-layout', 'fixed'); - }); - el.find('.treeview').each(function() { - var treeview = jQuery(this); - if (treeview.width()) { - treeview.css('width', treeview.width()); - treeview.children('.tree').css('table-layout', 'auto'); - } - }); - }; - jQuery(window).resize(function() { - Sao.View.resize(); - }); - }()); diff --git a/src/view/form.js b/src/view/form.js index 0e49acd763..bd366dfa1f 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -351,7 +351,6 @@ function eval_pyson(value){ var container = this.containers[j]; container.resize(); } - Sao.View.resize(this.el); }.bind(this)); }, set_value: function() { @@ -769,10 +768,8 @@ function eval_pyson(value){ 'href': '#' + tab_id }) .append(img) - .append(text) - .on('shown.bs.tab', function() { - Sao.View.resize(tab); - })).appendTo(this.nav); + .append(text)) + .appendTo(this.nav); pane.html(tab).appendTo(this.panes); if (!this.selected) { // Can not use .tab('show') diff --git a/src/view/tree.js b/src/view/tree.js index d03c363fa6..bd7fd061c0 100644 --- a/src/view/tree.js +++ b/src/view/tree.js @@ -77,10 +77,14 @@ this.table.addClass('table-bordered'); } this.el.append(this.table); + var colgroup = jQuery('').appendTo(this.table); + var col = jQuery('', { + 'class': 'selection-state', + }).appendTo(colgroup); this.thead = jQuery('').appendTo(this.table); var tr = jQuery(''); var th = jQuery('', { - 'class': 'selection' + 'class': 'selection-state' }); this.selection = jQuery('', { 'type': 'checkbox', @@ -101,11 +105,15 @@ } this.columns.forEach(function(column) { + col = jQuery('', { + 'class': column.attributes.widget, + }).appendTo(colgroup); th = jQuery('', { 'class': column.attributes.widget, }); var label = jQuery('