mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
refactoring on types
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Widget from "../core/Widget";
|
||||
import Widget from "../core/widget";
|
||||
import { Env } from "../types";
|
||||
|
||||
const template = `
|
||||
<div class="o_crm">
|
||||
@@ -6,7 +7,7 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class Discuss extends Widget {
|
||||
export default class Discuss extends Widget<Env> {
|
||||
name = "crm";
|
||||
template = template;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Widget from "../core/Widget";
|
||||
import Widget from "../core/widget";
|
||||
import { Env } from "../types";
|
||||
|
||||
const template = `
|
||||
<div>
|
||||
@@ -8,14 +9,14 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class Counter extends Widget {
|
||||
export default class Counter extends Widget<Env> {
|
||||
name = "counter";
|
||||
template = template;
|
||||
state = {
|
||||
counter: 0
|
||||
};
|
||||
|
||||
constructor(parent: Widget | null, props: {initialState?: number}) {
|
||||
constructor(parent: Widget<Env>, props: {initialState?: number}) {
|
||||
super(parent);
|
||||
this.state.counter = props.initialState || 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Widget from "../core/Widget";
|
||||
import Counter from "./Counter";
|
||||
import Widget from "../core/widget";
|
||||
import Counter from "./counter";
|
||||
import { Env } from "../types";
|
||||
|
||||
const template = `
|
||||
<div class="o_discuss">
|
||||
@@ -18,7 +19,7 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class Discuss extends Widget {
|
||||
export default class Discuss extends Widget<Env> {
|
||||
name = "discuss";
|
||||
template = template;
|
||||
widgets = { Counter };
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Widget from "../core/Widget";
|
||||
import Widget from "../core/widget";
|
||||
import { Action } from "../services/actions";
|
||||
import { Env } from "../types";
|
||||
|
||||
const template = `
|
||||
<div class="o_navbar">
|
||||
@@ -12,12 +13,12 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class Navbar extends Widget {
|
||||
export default class Navbar extends Widget<Env> {
|
||||
name = "navbar";
|
||||
template = template;
|
||||
|
||||
getUrl(action: Action) {
|
||||
const action_id = action.id;
|
||||
return this.env.services.router.formatURL("web", { action_id });
|
||||
const action_id = String(action.id);
|
||||
return this.env.router.formatURL("web", { action_id });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Widget, { Env } from "../core/Widget";
|
||||
import Navbar from "./Navbar";
|
||||
import Widget from "../core/widget";
|
||||
import Navbar from "./navbar";
|
||||
import { Action } from "../services/actions";
|
||||
import { Env } from "../types";
|
||||
|
||||
const template = `
|
||||
<div class="o_web_client">
|
||||
@@ -11,11 +12,10 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class RootWidget extends Widget {
|
||||
export default class RootWidget extends Widget<Env> {
|
||||
name = "root";
|
||||
template = template;
|
||||
widgets = { Navbar };
|
||||
state = { validcounter: true };
|
||||
|
||||
constructor(env: Env) {
|
||||
super(env);
|
||||
@@ -23,7 +23,7 @@ export default class RootWidget extends Widget {
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.env.services.router.register(this, this.onUrlChange);
|
||||
this.env.router.register(this, this.onUrlChange);
|
||||
}
|
||||
|
||||
setMainWidget() {
|
||||
@@ -39,7 +39,7 @@ export default class RootWidget extends Widget {
|
||||
}
|
||||
|
||||
getAction(): Action {
|
||||
const routeInfo = this.env.services.router.getRouteInfo();
|
||||
const routeInfo = this.env.router.getRouteInfo();
|
||||
const actionID = parseInt(routeInfo.query.action_id);
|
||||
let actions: Action[] = this.env.services.actions;
|
||||
let action = actions.find(a => a.id === actionID);
|
||||
Reference in New Issue
Block a user