diff --git a/web_responsive/static/src/components/apps_menu/apps_menu.esm.js b/web_responsive/static/src/components/apps_menu/apps_menu.esm.js index 02146c74d..adcb3219f 100644 --- a/web_responsive/static/src/components/apps_menu/apps_menu.esm.js +++ b/web_responsive/static/src/components/apps_menu/apps_menu.esm.js @@ -3,7 +3,6 @@ * Copyright 2021 ITerra - Sergey Shebanin * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ -import {Dropdown} from "@web/core/dropdown/dropdown"; import {NavBar} from "@web/webclient/navbar/navbar"; import {useAutofocus, useBus, useService} from "@web/core/utils/hooks"; import {useHotkey} from "@web/core/hotkeys/hotkey_hook"; @@ -20,11 +19,9 @@ const {useState, useRef} = owl.hooks; patch(WebClient.prototype, "web_responsive.DefaultAppsMenu", { setup() { this._super(); - useBus(Dropdown.bus, "state-changed", (payload) => { - if (payload.emitter.el.classList.contains("o_navbar_apps_menu")) { - this.el.classList.toggle("o_apps_menu_opened", payload.newState.open); - this.el.classList.toggle("o_first_app", false); - } + useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", (payload) => { + this.el.classList.toggle("o_apps_menu_opened", payload); + this.el.classList.toggle("o_first_app", false); }); }, _loadDefaultApp() { @@ -41,11 +38,20 @@ patch(WebClient.prototype, "web_responsive.DefaultAppsMenu", { /** * @extends Dropdown */ -export class AppsMenu extends Dropdown { +export class AppsMenu extends Component { setup() { super.setup(); - useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => this.close()); - useBus(this.env.bus, "APPS_MENU:CLOSE", () => this.close()); + this.state = useState({open: false}); + useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => { + this.setState(false); + }); + useBus(this.env.bus, "APPS_MENU:CLOSE", () => { + this.setState(false); + }); + } + setState(state) { + this.state.open = state; + this.env.bus.trigger("APPS_MENU:STATE_CHANGED", state); } } @@ -110,6 +116,7 @@ export class AppsMenuSearchBar extends Component { this.state = useState({ results: [], offset: 0, + hasResults: false, }); useAutofocus({selector: "input"}); this.searchBarInput = useRef("SearchBarInput"); @@ -152,10 +159,10 @@ export class AppsMenuSearchBar extends Component { */ _searchMenus() { const query = this.searchBarInput.el.value; - this.state.results = - query === "" - ? [] - : fuzzyLookup(query, _.keys(this._searchableMenus), (k) => k); + this.state.hasResults = query !== ""; + this.state.results = this.state.hasResults + ? fuzzyLookup(query, _.keys(this._searchableMenus), (k) => k) + : []; } /** @@ -222,11 +229,14 @@ export class AppsMenuSearchBar extends Component { const query = this.searchBarInput.el.value; if (query) { this.searchBarInput.el.value = ""; + this.state.results = []; + this.state.hasResults = false; } else { - this.env.bus.trigger("APPS_MENU:CLOSE"); + this.env.bus.trigger("ACTION_MANAGER:UI-UPDATED"); } } } } +AppsMenu.template = "web_responsive.AppsMenu"; AppsMenuSearchBar.template = "web_responsive.AppsMenuSearchResults"; Object.assign(NavBar.components, {AppsMenu, AppsMenuSearchBar}); diff --git a/web_responsive/static/src/components/apps_menu/apps_menu.xml b/web_responsive/static/src/components/apps_menu/apps_menu.xml index 5811f6f85..1ecaa5af6 100644 --- a/web_responsive/static/src/components/apps_menu/apps_menu.xml +++ b/web_responsive/static/src/components/apps_menu/apps_menu.xml @@ -6,47 +6,59 @@ - - - - - + - - -
- + t-foreach="apps" + t-as="app" + t-key="app.id" + class="o_app" + t-att-class="{ o_dropdown_active: menuService.getCurrentApp() === app }" + payload="app" + > + + +
+ - + + + + +
- - +
@@ -72,9 +85,4 @@
- - - fade - -