refactoring, work on environment

This commit is contained in:
Géry Debongnie
2019-01-23 14:28:41 +01:00
parent 08938d2334
commit 76fedae5a9
18 changed files with 138 additions and 63 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import Widget from "../core/widget";
import { Env } from "../types";
import { Env } from "../env";
const template = `
<div class="o_crm">
+1 -1
View File
@@ -1,5 +1,5 @@
import Widget from "../core/widget";
import { Env } from "../types";
import { Env } from "../env";
const template = `
<div>
+1 -1
View File
@@ -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">
+10 -3
View File
@@ -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);
}
}
+3 -3
View File
@@ -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);