Skip to content

Commit a99acf9

Browse files
committed
[IMP] awesome_owl: add a Todo List
Add a TodoList and a TodoItem class. Show a basic todo List
1 parent fd3d68a commit a99acf9

File tree

5 files changed

+54
-8
lines changed

5 files changed

+54
-8
lines changed

awesome_owl/static/src/playground.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import { Component, useState, markup } from "@odoo/owl";
44
import { Counter } from "./counter/counter";
55
import { Card } from "./card/card";
6+
import { TodoList } from "./todolist/todolist";
67

78
export class Playground extends Component {
89
static template = "awesome_owl.playground";
9-
static components = { Counter, Card };
10+
static components = { Counter, Card, TodoList };
1011

1112

1213
setup() {

awesome_owl/static/src/playground.xml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
<t t-name="awesome_owl.playground">
55
<div class="p-3">
6-
hello world
7-
<Counter onChange.bind="incrementSum"/>
8-
<Counter onChange.bind="incrementSum"/>
9-
<Counter onChange.bind="incrementSum"/>
10-
<Card title="'My Card'" content="someText"/>
11-
<Card title="'Card 2'" content="someHTML"/>
12-
<t t-esc="this.sum.value.toString()"/>
6+
<div>
7+
hello world
8+
<Counter onChange.bind="incrementSum"/>
9+
<Counter onChange.bind="incrementSum"/>
10+
<Counter onChange.bind="incrementSum"/>
11+
<Card title="'My Card'" content="someText"/>
12+
<Card title="'Card 2'" content="someHTML"/>
13+
<t t-esc="this.sum.value.toString()"/>
14+
</div>
15+
<TodoList />
1316
</div>
1417
</t>
1518

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import { Component, useState, xml } from "@odoo/owl";
3+
4+
export class TodoItem extends Component {
5+
static template = xml`<div><t t-esc="todo.value.id"/><br/><t t-esc="todo.value.description"/></div>`;
6+
static props = {
7+
todo : {
8+
id: { type: Number },
9+
description: { type: String },
10+
isCompleted: { type: Boolean }
11+
}
12+
}
13+
14+
setup() {
15+
this.todo = useState({ value: this.props.todo })
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import { Component, useState, xml } from "@odoo/owl";
3+
import { TodoItem } from "./todoitem";
4+
5+
export class TodoList extends Component {
6+
static template = "awesome_owl.todolist";
7+
static components = { TodoItem };
8+
9+
setup() {
10+
this.todos = useState([{ id: 3, description: "buy milk", isCompleted: false }]);
11+
}
12+
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.todolist">
5+
<div class="card d-inline-block m-2">
6+
<t t-foreach="todos" t-as="i" t-key="i.id">
7+
<TodoItem todo="i"/>
8+
</t>
9+
</div>
10+
</t>
11+
12+
</templates>

0 commit comments

Comments
 (0)