Skip to content

Commit 0135233

Browse files
committed
[IMP] estate: corretions after code review
1 parent fceec12 commit 0135233

22 files changed

+120
-66
lines changed

awesome_owl/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
('include', 'web._assets_backend_helpers'),
3333
'web/static/src/scss/pre_variables.scss',
3434
'web/static/lib/bootstrap/scss/_variables.scss',
35+
'web/static/lib/bootstrap/scss/_maps.scss',
3536
('include', 'web._assets_bootstrap'),
3637
('include', 'web._assets_core'),
3738
'web/static/src/libs/fontawesome/css/font-awesome.css',

awesome_owl/static/src/counter/counter.js

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

33
export class Counter extends Component {
44
static template = "awesome_owl.Counter";
5+
static props = {
6+
onChange: { type: Function, optional: true }
7+
}
58

69
setup() {
710
this.state = useState({ value: 0 });
811
}
912

1013
increment() {
1114
this.state.value++;
15+
if (this.props.onChange) {
16+
this.props.onChange();
17+
}
1218
}
1319

1420
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import { Component, useState, markup } from "@odoo/owl";
22
import { Counter } from "./counter/counter"
33
import { Card } from "./card/card";
4+
import { TodoList } from "./todo_list/todo_list";
45

56
export class Playground extends Component {
67
static template = "awesome_owl.Playground";
7-
static components = { Counter, Card };
8-
9-
value1 = "<div class='text-primary'>test</div>";
10-
value2 = markup("<a href='odoo.com'>test2</a>");
8+
static components = { Counter, Card, TodoList };
119

1210
setup() {
11+
this.value1 = "<div class='text-primary'>test</div>";
12+
this.value2 = markup("<a href='odoo.com'>test2</a>");
13+
this.state = useState({ sum : 0 });
14+
}
15+
16+
implementSum() {
17+
this.state.sum++;
1318
}
1419

1520
}

awesome_owl/static/src/playground.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
hello world
77
</div>
88
<div>
9-
<Counter/>
10-
<Counter/>
9+
<Counter onChange.bind="implementSum"/>
10+
<Counter onChange.bind="implementSum"/>
1111
</div>
1212
<div>
1313
<Card title="'card 1'" content="value1"/>
1414
<Card title="'card 2'" content="value2"/>
1515
</div>
16+
<div>
17+
The sum is: <t t-esc="state.sum"/>
18+
</div>
19+
<p></p>
20+
<div>
21+
<TodoList/>
22+
</div>
1623
</t>
1724

1825
</templates>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, useState } from "@odoo/owl"
2+
3+
export class TodoItem extends Component {
4+
static template = "awesome_owl.TodoItem";
5+
static props = {
6+
todo : {
7+
type: Object,
8+
shape: {
9+
id: Number,
10+
description: String,
11+
isCompleted: Boolean }
12+
}
13+
}
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.TodoItem">
5+
<div>
6+
<p>Id: <t t-esc="todo.id"/></p>
7+
<p>Description: <t t-esc="todo.description"/></p>
8+
</div>
9+
</t>
10+
11+
</templates>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, useState } from "@odoo/owl"
2+
import { TodoItem } from "./todo_item"
3+
4+
export class TodoList extends Component {
5+
static template = "awesome_owl.TodoList";
6+
static components = { TodoItem };
7+
8+
setup() {
9+
this.todos = useState([
10+
{ id:1, description: "buy bread", isCompleted: false },
11+
{ id:2, description: "buy milk", isCompleted: false },
12+
])
13+
}
14+
}
15+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.TodoList">
5+
<p>Todo List:</p>
6+
<t t-foreach="todos" t-as="todo" t-key="todo.id">
7+
<p><t t-esc="todo.id"/>. <t t-esc="todo.description"/></p>
8+
</t>
9+
</t>
10+
11+
</templates>

estate/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2-
31
from . import models

estate/__manifest__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
'views/estate_menus.xml',
1717
'views/res_users_views.xml',
1818
],
19-
'demo': [
20-
],
2119
'installable': True,
2220
'application': True,
2321
'license': 'LGPL-3',

0 commit comments

Comments
 (0)