[FIX] web: do not display notebook ul element if all pages hidden

before this commit: if all pages are hidden then notebook ul was still visible
due to which border for notebook ul element was displayed.

after this commit: if all pages are hidden then we hides notebook ul element
as well, so that we don't have empty border line of empty notebook.

task-2411651

closes odoo/odoo#63420

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Mohammed Shekha
2021-06-25 07:28:47 +00:00
committed by Simon Genin (ges)
parent 216b07eb46
commit ae4cb866de
2 changed files with 35 additions and 0 deletions
@@ -1007,6 +1007,8 @@ var FormRenderer = BasicRenderer.extend({
self.inactiveNotebooks.push(renderedTabs);
}
}
// if all pages are invisible then hide notebooks header's ul as well
$headers.toggleClass('o_invisible_modifier', !$headers.find('li:not(.o_invisible_modifier)').length);
},
});
});
@@ -947,6 +947,39 @@ QUnit.module('Views', {
form.destroy();
});
QUnit.test('hide notebook element if all pages hidden', async function (assert) {
assert.expect(4);
const form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: `<form string="Partners">
<sheet>
<field name="bar"/>
<notebook class="new_class">
<page string="Foo" attrs="{'invisible': [['bar', '=', true]]}">
<field name="foo"/>
</page>
</notebook>
</sheet>
</form>`,
});
assert.ok(form.$('.o_notebook .nav li:not(.o_invisible_modifier)').length,
"there should be visible page");
assert.notOk(form.$('.o_notebook .nav').hasClass('o_invisible_modifier'),
'the notebook headers should not be hidden if one of the page is visible');
await testUtils.dom.click(form.$('.o_field_boolean input'));
assert.notOk(form.$('.o_notebook .nav li:not(.o_invisible_modifier)').length,
"there should not be any visible page");
assert.ok(form.$('.o_notebook .nav').hasClass('o_invisible_modifier'),
'the notebook headers should be hidden if none of the page is visible');
form.destroy();
});
QUnit.test('autofocus on second notebook page', async function (assert) {
assert.expect(2);