mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
refactoring, work on environment
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Widget from "../core/widget";
|
||||
import { Env } from "../types";
|
||||
import { Env } from "../env";
|
||||
|
||||
const template = `
|
||||
<div class="o_crm">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Widget from "../core/widget";
|
||||
import { Env } from "../types";
|
||||
import { Env } from "../env";
|
||||
|
||||
const template = `
|
||||
<div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Widget from "../core/widget";
|
||||
import Counter from "./counter";
|
||||
import { Env } from "../types";
|
||||
import { Env } from "../env";
|
||||
|
||||
const template = `
|
||||
<div class="o_discuss">
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import Widget from "../core/widget";
|
||||
import { Action } from "../services/actions";
|
||||
import { Env } from "../types";
|
||||
import { Env } from "../env";
|
||||
|
||||
const template = `
|
||||
<div class="o_navbar">
|
||||
<span class="title">Odoo</span>
|
||||
<ul>
|
||||
<li t-foreach="env.services.actions" t-as="action">
|
||||
<a t-att-href="getUrl(action)"><t t-esc="action.title"/></a>
|
||||
<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>
|
||||
@@ -21,4 +23,9 @@ export default class Navbar extends Widget<Env> {
|
||||
const action_id = String(action.id);
|
||||
return this.env.router.formatURL("web", { action_id });
|
||||
}
|
||||
|
||||
activateAction(action: Action, event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
this.env.actionManager.doAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Widget from "../core/widget";
|
||||
import Navbar from "./navbar";
|
||||
import { Action } from "../services/actions";
|
||||
import { Env } from "../types";
|
||||
import { Env } from "../env";
|
||||
|
||||
const template = `
|
||||
<div class="o_web_client">
|
||||
@@ -39,9 +39,9 @@ export default class RootWidget extends Widget<Env> {
|
||||
}
|
||||
|
||||
getAction(): Action {
|
||||
const routeInfo = this.env.router.getRouteInfo();
|
||||
const routeInfo = this.env.router.getRoute();
|
||||
const actionID = parseInt(routeInfo.query.action_id);
|
||||
let actions: Action[] = this.env.services.actions;
|
||||
let actions: Action[] = this.env.actions;
|
||||
let action = actions.find(a => a.id === actionID);
|
||||
if (!action) {
|
||||
action = actions.find(a => a.default === true);
|
||||
|
||||
Reference in New Issue
Block a user