Files
owl/web/static/src/ts/widgets/Navbar.ts
T

32 lines
821 B
TypeScript
Raw Normal View History

2019-01-24 10:33:11 +01:00
import { Widget } from "../core/widget";
import { Action } from "../services/actions";
2019-01-23 14:28:41 +01:00
import { Env } from "../env";
const template = `
<div class="o_navbar">
<span class="title">Odoo</span>
<ul>
2019-01-23 14:28:41 +01:00
<li t-foreach="env.actions" t-as="action">
<a t-on-click="activateAction(action)" t-att-href="getUrl(action)">
<t t-esc="action.title"/>
</a>
</li>
</ul>
</div>
`;
2019-01-24 10:33:11 +01:00
export class Navbar extends Widget<Env> {
name = "navbar";
template = template;
getUrl(action: Action) {
2019-01-23 11:12:54 +01:00
const action_id = String(action.id);
return this.env.router.formatURL("web", { action_id });
}
2019-01-23 14:28:41 +01:00
activateAction(action: Action, event: MouseEvent) {
event.preventDefault();
this.env.actionManager.doAction(action);
}
}