From e6fd9ccdf0518e82312cdac21f06430d145acda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 13 Apr 2018 16:55:40 +0200 Subject: [PATCH] [FIX] web: properly display buttonbox for large screens In the form view, a new problem appeared since we introduced the extra device size_class: the buttonbox was folded for large screens, even if there is only two buttons. The reason is that the form renderer code used a list to map size class numbers to the number of buttons allowed to be displayed. With the extra size class, this number was undefined, which caused an issue. --- .../static/src/js/views/form/form_renderer.js | 2 +- addons/web/static/tests/views/form_tests.js | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) 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 94e870b78d6..9d706781f73 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -335,7 +335,7 @@ var FormRenderer = BasicRenderer.extend({ var visible_buttons = buttons_partition[1]; // Get the unfolded buttons according to window size - var nb_buttons = [2, 2, 4, 6, 7][config.device.size_class]; + var nb_buttons = [2, 2, 4, 6][config.device.size_class] || 7; var unfolded_buttons = visible_buttons.slice(0, nb_buttons).concat(invisible_buttons); // Get the folded buttons diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 6c192bff051..0fd60afb402 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -4021,6 +4021,35 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('display correctly buttonbox, in large size class', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '
' + + '' + + '' + + '
' + + '
', + res_id: 2, + config: { + device: {size_class: 5}, + }, + }); + + assert.strictEqual(form.$('.oe_button_box').children().length, 2, + "button box should contain two children"); + + form.destroy(); + }); + QUnit.test('one2many default value creation', function (assert) { assert.expect(1);