mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
work on demo app, add demo:dev command
This commit is contained in:
@@ -23,19 +23,20 @@ npm run bundle:core:watch
|
|||||||
|
|
||||||
## Demo page
|
## Demo page
|
||||||
|
|
||||||
There are three commands that can be used to play with the demo application:
|
There are three main commands that can be used to play with the demo application:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm run demo:build
|
npm run demo:build
|
||||||
npm run demo:watch
|
|
||||||
npm run demo:serve
|
npm run demo:serve
|
||||||
|
npm run demo:watch
|
||||||
```
|
```
|
||||||
|
|
||||||
- *build* prepare a folder with all the static files compiled. It is located in
|
- *demo:build* prepare a folder with all the static files compiled. It is
|
||||||
dist/demo
|
located in dist/demo
|
||||||
- *watch* recompile the typescript files as soon as they are changed
|
- *demo:serve* simply starts a live-server pointing to the dist/demo (which will
|
||||||
- *serve* starts a live-server pointing to the dist/demo (which will reload the
|
also reload the page whenever the static files are changed)
|
||||||
page whenever the files are changed)
|
- *demo:dev* is a single command useful for developping: it will watch the
|
||||||
|
source files, recompile them as needed, starts a live-server.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Web Client */
|
||||||
|
.o_web_client {
|
||||||
|
height: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 40px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Navbar */
|
||||||
|
.o_navbar {
|
||||||
|
background-color: #875A7B;
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
span.title {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
display: inline-flex;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+1
-1
@@ -5,11 +5,11 @@
|
|||||||
<title>Odoo Web Core Demo</title>
|
<title>Odoo Web Core Demo</title>
|
||||||
<script src="almond.js"></script>
|
<script src="almond.js"></script>
|
||||||
<script src="main.js"></script>
|
<script src="main.js"></script>
|
||||||
|
<link rel="stylesheet" href="app.css">
|
||||||
<script>
|
<script>
|
||||||
require('main');
|
require('main');
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import Widget from "../../src/core/widget";
|
||||||
|
|
||||||
|
const template = `
|
||||||
|
<div class="o_navbar">
|
||||||
|
<span class="title">Odoo</span>
|
||||||
|
<ul>
|
||||||
|
<li t-foreach="state.items" t-as="item">
|
||||||
|
<a href="someaction"><t t-esc="item.title"/></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default class Navbar extends Widget {
|
||||||
|
name = "navbar";
|
||||||
|
template = template;
|
||||||
|
state = {
|
||||||
|
items: [{title: 'Discuss'}, {title: 'CRM'}]
|
||||||
|
};
|
||||||
|
}
|
||||||
+18
-14
@@ -1,27 +1,31 @@
|
|||||||
import Widget from "../../src/core/widget";
|
import Widget from "../../src/core/widget";
|
||||||
import Counter from "./Counter";
|
import Counter from "./Counter";
|
||||||
|
import Navbar from "./Navbar";
|
||||||
|
|
||||||
const template = `
|
const template = `
|
||||||
<div>
|
<div class="o_web_client">
|
||||||
<span>Root Widget</span>
|
<t t-widget="Navbar"/>
|
||||||
<button t-on-click="resetCounter">Reset</button>
|
<div class="o_content">
|
||||||
<button t-on-click="resetCounterAsync">Reset in 3s</button>
|
<span>Root Widget</span>
|
||||||
<button t-on-click="toggle">Toggle Counter</button>
|
<button t-on-click="resetCounter">Reset</button>
|
||||||
<input/>
|
<button t-on-click="resetCounterAsync">Reset in 3s</button>
|
||||||
<t t-if="state.validcounter">
|
<button t-on-click="toggle">Toggle Counter</button>
|
||||||
<t t-widget="Counter" t-ref="counter" t-props="{initialState:4}"/>
|
<input/>
|
||||||
</t>
|
<t t-if="state.validcounter">
|
||||||
<t t-else="1">
|
<t t-widget="Counter" t-ref="counter" t-props="{initialState:4}"/>
|
||||||
<t t-widget="Counter" t-ref="counter" t-props="{initialState:7}"/>
|
</t>
|
||||||
</t>
|
<t t-else="1">
|
||||||
<div ref="target"/>
|
<t t-widget="Counter" t-ref="counter" t-props="{initialState:7}"/>
|
||||||
|
</t>
|
||||||
|
<div ref="target"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default class RootWidget extends Widget {
|
export default class RootWidget extends Widget {
|
||||||
name = "root";
|
name = "root";
|
||||||
template = template;
|
template = template;
|
||||||
widgets = { Counter };
|
widgets = { Counter, Navbar };
|
||||||
state = { validcounter: true};
|
state = { validcounter: true};
|
||||||
|
|
||||||
resetCounter(ev: MouseEvent) {
|
resetCounter(ev: MouseEvent) {
|
||||||
|
|||||||
+1
-14
@@ -1,23 +1,10 @@
|
|||||||
///<amd-module name="main" />
|
///<amd-module name="main" />
|
||||||
|
|
||||||
// import QWeb from "../../src/core/qweb_vdom";
|
|
||||||
// import {init} from "../../src/libs/snabbdom/src/snabbdom"
|
|
||||||
// import h from "../../src/libs/snabbdom/src/h"
|
|
||||||
// import sdProps from "../../src/libs/snabbdom/src/modules/props"
|
|
||||||
// import sdListeners from "../../src/libs/snabbdom/src/modules/eventlisteners"
|
|
||||||
|
|
||||||
// const patch = init([sdProps, sdListeners]);
|
|
||||||
|
|
||||||
// (<any>window).h = h;
|
|
||||||
// (<any>window).patch = patch;
|
|
||||||
// (<any>window).QWeb = QWeb;
|
|
||||||
// import Counter from "./Counter";
|
|
||||||
import RootWidget from "./RootWidget";
|
import RootWidget from "./RootWidget";
|
||||||
import env from "./env";
|
import env from "./env";
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async function() {
|
document.addEventListener("DOMContentLoaded", async function() {
|
||||||
const rootWidget = new RootWidget(null);
|
const rootWidget = new RootWidget(null);
|
||||||
rootWidget.setEnvironment(env);
|
rootWidget.setEnvironment(env);
|
||||||
const mainDiv = document.getElementById("app")!;
|
await rootWidget.mount(document.body);
|
||||||
await rootWidget.mount(mainDiv);
|
|
||||||
});
|
});
|
||||||
|
|||||||
+7
-4
@@ -8,11 +8,12 @@
|
|||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"bundle:core": "tsc -m es6 --lib es2017,dom --target esnext --outdir dist src/bundles/core.ts && rollup dist/bundles/core.js --file dist/bundle-core.js --format iife",
|
"bundle:core": "tsc -m es6 --lib es2017,dom --target esnext --outdir dist src/bundles/core.ts && rollup dist/bundles/core.js --file dist/bundle-core.js --format iife",
|
||||||
"bundle:core:watch": "npm run bundle:core -- --watch",
|
"bundle:core:watch": "npm run bundle:core -- --watch",
|
||||||
"demo:build": "cp -r demo/ dist/demo && npm run demo:build:js",
|
"demo:build": "cp -r demo/ dist/demo && npm run demo:build:js && npm run demo:build:css",
|
||||||
|
"demo:build:css": "sass demo/app.scss dist/demo/app.css",
|
||||||
"demo:build:js": "tsc --allowjs -m amd --lib es2017,dom --target esnext --outfile dist/demo/main.js demo/src/main.ts",
|
"demo:build:js": "tsc --allowjs -m amd --lib es2017,dom --target esnext --outfile dist/demo/main.js demo/src/main.ts",
|
||||||
"predemo:watch": "npm run demo:build",
|
"demo:serve": "live-server dist/demo/",
|
||||||
"demo:watch": "npm run demo:build:js -- --watch",
|
"predemo:dev": "npm run demo:build",
|
||||||
"demo:serve": "live-server dist/demo/"
|
"demo:dev": "npm-run-all --parallel \"demo:build:* -- --watch\" demo:serve"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -28,8 +29,10 @@
|
|||||||
"@types/jest": "^23.3.12",
|
"@types/jest": "^23.3.12",
|
||||||
"jest": "^23.6.0",
|
"jest": "^23.6.0",
|
||||||
"live-server": "^1.2.1",
|
"live-server": "^1.2.1",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
"rollup": "^1.1.0",
|
"rollup": "^1.1.0",
|
||||||
"rollup-plugin-typescript2": "^0.19.0",
|
"rollup-plugin-typescript2": "^0.19.0",
|
||||||
|
"sass": "^1.16.1",
|
||||||
"snabbdom-to-html": "^5.1.1",
|
"snabbdom-to-html": "^5.1.1",
|
||||||
"source-map-support": "^0.5.10",
|
"source-map-support": "^0.5.10",
|
||||||
"ts-jest": "^23.10.5",
|
"ts-jest": "^23.10.5",
|
||||||
|
|||||||
Reference in New Issue
Block a user