File tree 4 files changed +10
-1
lines changed
4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ export class TodoItem extends Component {
5
5
static props = {
6
6
todo : Object ,
7
7
onToggleState : Function ,
8
+ onRemoveTodo : Function ,
8
9
}
9
10
}
Original file line number Diff line number Diff line change 4
4
<t t-name =" awesome_owl.todoitem" >
5
5
<input type =" checkbox" t-on-change =" ()=> props.onToggleState(props.todo.id)" />
6
6
<t t-out =" props.todo.id+'. '+props.todo.description" />
7
+ <span t-on-click =" ()=> props.onRemoveTodo(props.todo.id)" class =" fa fa-remove" ></span >
7
8
</t >
8
9
9
10
</templates >
Original file line number Diff line number Diff line change @@ -28,4 +28,11 @@ export class TodoList extends Component {
28
28
let todo = this . state . todos . find ( todo => todo . id === todoId ) ;
29
29
todo . isCompleted = ! todo . isCompleted ;
30
30
}
31
+
32
+ removeTodo ( todoId ) {
33
+ let index = this . state . todos . findIndex ( todo => todo . id === todoId ) ;
34
+ if ( index >= 0 ) {
35
+ this . state . todos . splice ( index , 1 ) ;
36
+ }
37
+ }
31
38
}
Original file line number Diff line number Diff line change 7
7
<t t-foreach =" state.todos" t-as =" i" t-key =" i.id" >
8
8
<div style =" border: 1px solid black" >
9
9
<div t-att-class =" {'text-muted': i.isCompleted, 'text-decoration-line-through': i.isCompleted}" >
10
- <TodoItem todo = " i" onToggleState.bind=" toggleState" />
10
+ <TodoItem todo = " i" onToggleState.bind=" toggleState" onRemoveTodo.bind= " removeTodo " />
11
11
</div >
12
12
</div >
13
13
</t >
You can’t perform that action at this time.
0 commit comments