move demo code to examples/

This commit is contained in:
Géry Debongnie
2019-03-15 12:15:37 +01:00
parent d99ea4c9f4
commit 46aedf78af
1638 changed files with 32 additions and 29 deletions
+33
View File
@@ -0,0 +1,33 @@
///<amd-module name="main" />
import { makeEnv, linkStoreToEnv } from "./env";
import { loadMenus, loadTemplates } from "./loaders";
import { actionRegistry, viewRegistry } from "./registries";
import { rpc } from "./services/ajax";
import { Router } from "./services/router";
import { Store } from "./store/store";
import { Root } from "./ui/root";
//------------------------------------------------------------------------------
// Web Client Bootstrapping
//------------------------------------------------------------------------------
document.addEventListener("DOMContentLoaded", async function() {
const services = {
rpc,
router: new Router()
};
const templates = await loadTemplates();
const menuInfo = loadMenus();
const env = makeEnv({ services, templates, actionRegistry, viewRegistry });
const store = new Store(env, menuInfo);
linkStoreToEnv(env, store);
// Creating root widget
const rootWidget = new Root(env, store);
await rootWidget.mount(document.body);
// For debugging purpose, we keep a reference to the root widget in odoo
(<any>window).odoo.rootWidget = rootWidget;
});