mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
basic project infrastructure
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import Widget from "../../src/core/widget";
|
||||
|
||||
const template = `
|
||||
<div t-debug="1">
|
||||
<button t-on-click="increment(-1)">-</button>
|
||||
<span>Value: <t t-esc="state.counter"/></span>
|
||||
<button t-on-click="increment(1)">+</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class Counter extends Widget {
|
||||
name = "counter";
|
||||
template = template;
|
||||
state = {
|
||||
counter: 0
|
||||
};
|
||||
|
||||
constructor(parent: Widget, initialState?: number) {
|
||||
super(parent);
|
||||
this.state.counter = initialState || 0;
|
||||
}
|
||||
|
||||
increment(delta: number) {
|
||||
this.updateState({ counter: this.state.counter + delta });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Env } from "../../src/core/widget";
|
||||
import QWeb from "../../src/core/qweb";
|
||||
|
||||
const qweb = new QWeb();
|
||||
|
||||
const env: Env = {
|
||||
qweb: qweb,
|
||||
services: {}
|
||||
};
|
||||
|
||||
export default env;
|
||||
@@ -0,0 +1,12 @@
|
||||
///<amd-module name="main" />
|
||||
|
||||
// import RootWidget from "./RootWidget";
|
||||
import Counter from "./Counter";
|
||||
import env from "./env";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async function() {
|
||||
const rootWidget = new Counter(null);
|
||||
rootWidget.setEnvironment(env);
|
||||
const mainDiv = document.getElementById("app")!;
|
||||
await rootWidget.mount(mainDiv);
|
||||
});
|
||||
Reference in New Issue
Block a user