File tree Expand file tree Collapse file tree 5 files changed +54
-8
lines changed Expand file tree Collapse file tree 5 files changed +54
-8
lines changed Original file line number Diff line number Diff line change 3
3
import { Component , useState , markup } from "@odoo/owl" ;
4
4
import { Counter } from "./counter/counter" ;
5
5
import { Card } from "./card/card" ;
6
+ import { TodoList } from "./todolist/todolist" ;
6
7
7
8
export class Playground extends Component {
8
9
static template = "awesome_owl.playground" ;
9
- static components = { Counter, Card } ;
10
+ static components = { Counter, Card, TodoList } ;
10
11
11
12
12
13
setup ( ) {
Original file line number Diff line number Diff line change 3
3
4
4
<t t-name =" awesome_owl.playground" >
5
5
<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 />
13
16
</div >
14
17
</t >
15
18
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments