[FIX] web: use OnboardingBanner as default banner
Before this commit, the List and Kanban views did not allow the use of
a Banner without adding it in the View definition.
Like this:
```
export const listView = {
...
Banner: OnboardingBanner,
...
}
```
Now, we use by default OnboardingBanner as Banner if no other has been
defined in the View definition.
closes odoo/odoo#95945
Related: odoo/enterprise#29452
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { ControlPanel } from "@web/search/control_panel/control_panel";
|
||||
import { SearchPanel } from "@web/search/search_panel/search_panel";
|
||||
import { pick } from "@web/core/utils/objects";
|
||||
|
||||
const { Component } = owl;
|
||||
|
||||
@@ -10,11 +9,7 @@ const { Component } = owl;
|
||||
* @returns {Object}
|
||||
*/
|
||||
export function extractLayoutComponents(params) {
|
||||
return {
|
||||
ControlPanel: params.ControlPanel || ControlPanel,
|
||||
SearchPanel: params.SearchPanel || SearchPanel,
|
||||
Banner: params.Banner || false,
|
||||
};
|
||||
return pick(params, "ControlPanel", "SearchPanel", "Banner");
|
||||
}
|
||||
|
||||
export class Layout extends Component {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</t>
|
||||
<t t-component="components.ControlPanel" slots="controlPanelSlots" t-if="display.controlPanel"/>
|
||||
<div class="o_content" t-attf-class="{{props.className}}" t-att-class="{ o_component_with_search_panel: display.searchPanel }">
|
||||
<t t-component="components.Banner" t-if="components.Banner and display.banner"/>
|
||||
<t t-component="components.Banner" t-if="display.banner"/>
|
||||
<t t-component="components.SearchPanel" t-if="display.searchPanel"/>
|
||||
<t t-slot="default"/>
|
||||
</div>
|
||||
|
||||
@@ -1378,7 +1378,7 @@ export class SearchModel extends EventBus {
|
||||
* is instanciated in a view (this doesn't apply for any other action type).
|
||||
* @private
|
||||
* @param {Object} [display={}]
|
||||
* @returns {{ controlPanel: Object | false, searchPanel: boolean }}
|
||||
* @returns {{ controlPanel: Object | false, searchPanel: boolean, banner: boolean }}
|
||||
*/
|
||||
_getDisplay(display = {}) {
|
||||
const { viewTypes } = this.searchPanelInfo;
|
||||
|
||||
@@ -5,8 +5,11 @@ import { registry } from "@web/core/registry";
|
||||
import { KeepLast } from "@web/core/utils/concurrency";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { deepCopy, pick } from "@web/core/utils/objects";
|
||||
import { ControlPanel } from "@web/search/control_panel/control_panel";
|
||||
import { extractLayoutComponents } from "@web/search/layout";
|
||||
import { SearchPanel } from "@web/search/search_panel/search_panel";
|
||||
import { WithSearch } from "@web/search/with_search/with_search";
|
||||
import { OnboardingBanner } from "@web/views/onboarding_banner";
|
||||
import { useActionLinks } from "@web/views/view_hook";
|
||||
|
||||
const { Component, markRaw, onWillUpdateProps, onWillStart, toRaw, useSubEnv } = owl;
|
||||
@@ -22,6 +25,9 @@ const viewRegistry = registry.category("views");
|
||||
* @property {() => Object} getPagerProps
|
||||
* @property {Object[]} viewSwitcherEntry
|
||||
* @property {Object[]} viewSwitcherEntry
|
||||
* @property {Component} ControlPanel
|
||||
* @property {Component} SearchPanel
|
||||
* @property {Component} Banner
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -50,6 +56,9 @@ export function getDefaultConfig() {
|
||||
},
|
||||
viewSwitcherEntries: [],
|
||||
views: [],
|
||||
ControlPanel: ControlPanel,
|
||||
SearchPanel: SearchPanel,
|
||||
Banner: OnboardingBanner,
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -10633,4 +10633,31 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
assert.verifySteps(["notification"]);
|
||||
});
|
||||
|
||||
QUnit.test("renders banner_route", async (assert) => {
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban banner_route="/mybody/isacage">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div/>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
`,
|
||||
groupBy: ["bar"],
|
||||
async mockRPC(route) {
|
||||
if (route === "/mybody/isacage") {
|
||||
assert.step(route);
|
||||
return { html: `<div class="setmybodyfree">myBanner</div>` };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.verifySteps(["/mybody/isacage"]);
|
||||
assert.containsOnce(target, ".setmybodyfree");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14130,4 +14130,25 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
assert.containsNone(target, ".o_selected_row");
|
||||
});
|
||||
|
||||
QUnit.test("renders banner_route", async (assert) => {
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: `
|
||||
<tree banner_route="/mybody/isacage">
|
||||
<field name="foo"/>
|
||||
</tree>`,
|
||||
async mockRPC(route) {
|
||||
if (route === "/mybody/isacage") {
|
||||
assert.step(route);
|
||||
return { html: `<div class="setmybodyfree">myBanner</div>` };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.verifySteps(["/mybody/isacage"]);
|
||||
assert.containsOnce(target, ".setmybodyfree");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user