From cf178a2f068acd4b4c4fc2cda00b6ef8f6dc79c0 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 4 Jan 2018 16:17:14 +0100 Subject: [IMP] web,*: config: add XXS size to config.device In Less, the size_class XXS is defined and used in media queries. This rev. adds it in JS for sake of consistency. Code in addons comparing the size_class needed to be adapted due to the new XXS size_class. Moreover, we now use the helper 'config.device.isMobile' everywhere we should, instead of manually comparing the size_class. Finally, we changed the way the config.device has to be specified in the test environment. From now on, only the size_class should be set, and the isMobile flag is computed automatically. --- addons/web/static/src/js/views/basic/basic_view.js | 2 +- addons/web/static/src/js/views/form/form_renderer.js | 2 +- addons/web/static/src/js/views/graph/graph_renderer.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/views') diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js index f428a83cd41..df9f9807bfd 100644 --- a/addons/web/static/src/js/views/basic/basic_view.js +++ b/addons/web/static/src/js/views/basic/basic_view.js @@ -246,7 +246,7 @@ var BasicView = AbstractView.extend({ } } if (mode.indexOf(',') !== -1) { - mode = config.device.size_class !== config.device.SIZES.XS ? 'tree' : 'kanban'; + mode = config.device.isMobile ? 'kanban' : 'tree'; } if (mode === 'tree') { mode = 'list'; diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 779121de3e9..7d9c3cd2d78 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -279,7 +279,7 @@ var FormRenderer = BasicRenderer.extend({ var visible_buttons = buttons_partition[1]; // Get the unfolded buttons according to window size - var nb_buttons = [2, 4, 6, 7][config.device.size_class]; + var nb_buttons = [2, 2, 4, 6, 7][config.device.size_class]; var unfolded_buttons = visible_buttons.slice(0, nb_buttons).concat(invisible_buttons); // Get the folded buttons diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js index 4d51f8786d0..07155e327e3 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -20,7 +20,7 @@ var qweb = core.qweb; var CHART_TYPES = ['pie', 'bar', 'line']; // hide top legend when too many items for device size -var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); +var MAX_LEGEND_LENGTH = 25 * (Math.max(1, config.device.size_class)); return AbstractRenderer.extend({ className: "o_graph_svg_container", -- cgit v1.2.3