[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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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: '<form>' +
|
||||
'<div name="button_box" class="oe_button_box">' +
|
||||
'<button type="object" class="oe_stat_button" icon="fa-check-square">' +
|
||||
'<field name="bar"/>' +
|
||||
'</button>' +
|
||||
'<button type="object" class="oe_stat_button" icon="fa-check-square">' +
|
||||
'<field name="foo"/>' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>',
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user