[IMP] web: Only display search panel with sections

Before this commit, the search model would consider displaying a
search panel regardless of whether it had any sections.

Now, the search panel is considered non-displayable when there is no
sections.

X-original-commit: d3b191600b50fb052a956d1199730453789674e2
Part-of: odoo/odoo#77463
This commit is contained in:
Julien Mougenot
2021-09-30 10:38:29 +00:00
parent da8f749f56
commit 6dd7efed58
2 changed files with 25 additions and 3 deletions
@@ -1384,6 +1384,7 @@ export class SearchModel extends EventBus {
return {
controlPanel: "controlPanel" in display ? display.controlPanel : {},
searchPanel:
this.sections.size &&
(!this.view.type || viewTypes.includes(this.view.type)) &&
("searchPanel" in display ? display.searchPanel : true),
};
@@ -101,7 +101,7 @@ const makeTestComponent = ({ onWillStart, onWillUpdateProps } = {}) => {
TestComponent.components = { FilterMenu, GroupByMenu, SearchPanel };
TestComponent.template = xml`
<div class="o_test_component">
<SearchPanel />
<SearchPanel t-if="env.searchModel.display.searchPanel" />
<FilterMenu />
<GroupByMenu />
</div>`;
@@ -282,7 +282,29 @@ QUnit.module("Search", (hooks) => {
searchViewId: false,
display: { searchPanel: false },
});
assert.doesNotHaveClass(comp.el, "o_component_with_search_panel");
assert.containsNone(comp, ".o_search_panel");
assert.deepEqual(getDomain(), []); // initial domain
});
QUnit.test("basic rendering of a component with empty search panel", async (assert) => {
assert.expect(2);
serverData.views["partner,false,search"] = `<search><searchpanel /></search>`;
const { TestComponent, getDomain } = makeTestComponent();
const comp = await makeWithSearch({
serverData,
async mockRPC(route, { method, model }) {
if (/search_panel_/.test(method || route)) {
assert.step(`${method || route} on ${model}`);
}
},
Component: TestComponent,
resModel: "partner",
searchViewId: false,
});
assert.containsNone(comp, ".o_search_panel");
assert.deepEqual(getDomain(), []); // initial domain
});
@@ -299,7 +321,6 @@ QUnit.module("Search", (hooks) => {
Component: TestComponent,
resModel: "partner",
searchViewId: false,
view: { type: "kanban" },
});
assert.containsOnce(comp, ".o_search_panel");