Skip to content

Commit a25d65c

Browse files
committed
[REFINE] awesome_owl: 1. Displaying a counter
update module structure and enhance Playground component
1 parent 2d4daec commit a25d65c

File tree

5 files changed

+43
-33
lines changed

5 files changed

+43
-33
lines changed

awesome_owl/__manifest__.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,36 @@
1-
# -*- coding: utf-8 -*-
21
{
3-
'name': "Awesome Owl",
4-
5-
'summary': """
2+
"name": "Awesome Owl",
3+
"summary": """
64
Starting module for "Discover the JS framework, chapter 1: Owl components"
75
""",
8-
9-
'description': """
6+
"description": """
107
Starting module for "Discover the JS framework, chapter 1: Owl components"
118
""",
12-
13-
'author': "Odoo",
14-
'website': "https://www.odoo.com",
15-
9+
"author": "Odoo",
10+
"website": "https://www.odoo.com",
1611
# Categories can be used to filter modules in modules listing
1712
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
1813
# for the full list
19-
'category': 'Tutorials',
20-
'version': '0.1',
21-
14+
"category": "Tutorials",
15+
"version": "0.1",
2216
# any module necessary for this one to work correctly
23-
'depends': ['base', 'web'],
24-
'application': True,
25-
'installable': True,
26-
'data': [
27-
'views/templates.xml',
17+
"depends": ["base", "web"],
18+
"application": True,
19+
"installable": True,
20+
"data": [
21+
"views/templates.xml",
2822
],
29-
'assets': {
30-
'awesome_owl.assets_playground': [
31-
('include', 'web._assets_helpers'),
32-
'web/static/src/scss/pre_variables.scss',
33-
'web/static/lib/bootstrap/scss/_variables.scss',
34-
('include', 'web._assets_bootstrap'),
35-
('include', 'web._assets_core'),
36-
'web/static/src/libs/fontawesome/css/font-awesome.css',
37-
'awesome_owl/static/src/**/*',
23+
"assets": {
24+
"awesome_owl.assets_playground": [
25+
("include", "web._assets_helpers"),
26+
"web/static/src/scss/pre_variables.scss",
27+
"web/static/lib/bootstrap/scss/_variables.scss",
28+
"web/static/lib/bootstrap/scss/_maps.scss",
29+
("include", "web._assets_bootstrap"),
30+
("include", "web._assets_core"),
31+
"web/static/src/libs/fontawesome/css/font-awesome.css",
32+
"awesome_owl/static/src/**/*",
3833
],
3934
},
40-
'license': 'AGPL-3'
35+
"license": "AGPL-3",
4136
}

awesome_owl/static/src/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ const config = {
88
};
99

1010
// Mount the Playground component when the document.body is ready
11-
whenReady(() => mountComponent(Playground, document.body, config));
11+
whenReady(() => {
12+
const target = document.getElementById('app');
13+
if (target) {
14+
mountComponent(Playground, target, config);
15+
}
16+
});
1217

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import { Component } from "@odoo/owl";
1+
import { useState, Component } from "@odoo/owl";
22

33
export class Playground extends Component {
4-
static template = "awesome_owl.playground";
4+
static template = "my_module.Counter";
5+
6+
setup() {
7+
this.state = useState({ value: 0 });
8+
}
9+
10+
increment() {
11+
this.state.value++;
12+
}
513
}

awesome_owl/static/src/playground.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
33

4-
<t t-name="awesome_owl.playground">
4+
<t t-name="my_module.Counter">
55
<div class="p-3">
6-
hello world
6+
<p>Counter: <t t-esc="state.value"/></p>
7+
<button class="btn btn-primary" t-on-click="increment">Increment</button>
78
</div>
89
</t>
910

awesome_owl/views/templates.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</head>
99

1010
<body>
11+
<div id="app"></div>
1112
</body>
1213
</html>
1314
</template>

0 commit comments

Comments
 (0)