mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
small refactoring...
This commit is contained in:
@@ -1,14 +1,36 @@
|
||||
import { Widget } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
import { ActionStack } from "../services/action_manager";
|
||||
|
||||
const template = `
|
||||
<div class="o_content">
|
||||
<span>MAIN ACTION</span>
|
||||
<input/>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export class Action extends Widget<Env, {}> {
|
||||
name = "action";
|
||||
template = template;
|
||||
export interface Props {
|
||||
stack: ActionStack;
|
||||
}
|
||||
|
||||
export class Action extends Widget<Env, Props> {
|
||||
name = "action";
|
||||
template = `<div class="o_content"/>`;
|
||||
currentWidget: any;
|
||||
|
||||
mounted() {
|
||||
this.setContentWidget();
|
||||
}
|
||||
|
||||
shouldUpdate(nextProps: Props) {
|
||||
this.props = nextProps;
|
||||
this.setContentWidget();
|
||||
return false;
|
||||
}
|
||||
|
||||
async setContentWidget() {
|
||||
const info = this.props.stack[this.props.stack.length - 1];
|
||||
if (info && info.type === "client") {
|
||||
const Widget = info.Widget;
|
||||
let widget = new Widget(this, {});
|
||||
await widget.mount(this.el!);
|
||||
if (this.currentWidget) {
|
||||
this.currentWidget.destroy();
|
||||
}
|
||||
this.currentWidget = widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,20 @@ import { Env, Menu } from "../env";
|
||||
|
||||
const template = `
|
||||
<div class="o_navbar">
|
||||
<a aria-label="Applications" class="o_title fa fa-th" href="#" title="Applications" accesskey="h" t-on-click="toggleHomeMenu"/>
|
||||
<a aria-label="Applications" class="o_title fa fa-th" href="#" title="Applications" accesskey="h" t-on-click="toggleHome"/>
|
||||
<ul t-if="!props.inMenu">
|
||||
<li t-foreach="env.menus" t-as="menu">
|
||||
<a t-att-href="getUrl(menu)">
|
||||
<t t-esc="menu.title"/>
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="env.isMobile">MOBILEMODE</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export interface Props {
|
||||
toggleHomeMenu: () => void;
|
||||
toggleHome: () => void;
|
||||
inMenu: boolean;
|
||||
}
|
||||
|
||||
@@ -28,8 +29,8 @@ export class Navbar extends Widget<Env, Props> {
|
||||
return this.env.router.formatURL("", { action_id });
|
||||
}
|
||||
|
||||
toggleHomeMenu(ev: MouseEvent) {
|
||||
toggleHome(ev: MouseEvent) {
|
||||
ev.preventDefault();
|
||||
this.props.toggleHomeMenu();
|
||||
this.props.toggleHome();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user