File tree Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Expand file tree Collapse file tree 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 {
55 static props = {
66 todo : Object ,
77 onToggleState : Function ,
8+ onRemoveTodo : Function ,
89 }
910}
Original file line number Diff line number Diff line change 44 <t t-name =" awesome_owl.todoitem" >
55 <input type =" checkbox" t-on-change =" ()=> props.onToggleState(props.todo.id)" />
66 <t t-out =" props.todo.id+'. '+props.todo.description" />
7+ <span t-on-click =" ()=> props.onRemoveTodo(props.todo.id)" class =" fa fa-remove" ></span >
78 </t >
89
910</templates >
Original file line number Diff line number Diff line change @@ -28,4 +28,11 @@ export class TodoList extends Component {
2828 let todo = this . state . todos . find ( todo => todo . id === todoId ) ;
2929 todo . isCompleted = ! todo . isCompleted ;
3030 }
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+ }
3138}
Original file line number Diff line number Diff line change 77 <t t-foreach =" state.todos" t-as =" i" t-key =" i.id" >
88 <div style =" border: 1px solid black" >
99 <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 " />
1111 </div >
1212 </div >
1313 </t >
You can’t perform that action at this time.
0 commit comments