File tree Expand file tree Collapse file tree 6 files changed +23
-12
lines changed Expand file tree Collapse file tree 6 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export class Counter extends Component {
55    static  props  =  {  
66        value : { optional : true } , 
77        side_effect : { type : Function ,  optional : true } 
8-     } 
8+     } ; 
99
1010    setup ( )  { 
1111        this . state  =  useState ( {  value : this . props . value  ||  0 } ) ; 
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export class Playground extends Component {
1414    } 
1515
1616    get  sum ( )  { 
17-         return  this . state . val1  +  this . state . val2 
17+         return  this . state . val1  +  this . state . val2 ; 
1818    } 
1919
2020} 
Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ export class TodoItem extends Component {
55    static  props  =  { 
66        id : String , 
77        todo : { type : { description : String ,  isCompleted : Boolean } } , 
8-         toggleState : Function  
8+         toggleState : Function , 
9+         removeTodo : Function 
910    } 
1011
1112    setup ( )  { 
12-         this . id  =  this . props . id 
13-         this . todo  =  useState ( this . props . todo ) 
14-         this . toggleState  =  this . props . toggleState 
13+         this . id  =  this . props . id ; 
14+         this . todo  =  useState ( this . props . todo ) ; 
15+         this . toggleState  =  this . props . toggleState ; 
16+         this . removeTodo  =  this . props . removeTodo ; 
1517    } 
1618} 
Original file line number Diff line number Diff line change 55        <div  class =" todo_item-body" t-att-class =" {'text-muted text-decoration-line-through': this.todo.isCompleted}" 
66            <p  class =" todo_item-text" 
77                <input  type =" checkbox" t-att-checked =" this.todo.isCompleted" t-on-change =" this.toggleState" 
8-                 <t  t-esc =" this.id" t  t-out =" this.todo.description" 
8+                 <t  t-esc =" this.id" t  t-out =" this.todo.description"  < span   class = " fa fa-remove "   t-on-click = " this.removeTodo " /> 
99            </p >
1010        </div >
1111    </t >
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ import { TodoItem } from "./todo_item";
33import  {  useAutoFocus  }  from  "../utils" ; 
44
55export  class  TodoList  extends  Component  { 
6-     static  template  =  "awesome_owl.todo_list" 
7-     static  components  =  {  TodoItem } 
6+     static  template  =  "awesome_owl.todo_list" ; 
7+     static  components  =  {  TodoItem } ; 
88
99    setup ( )  { 
1010        useAutoFocus ( "todo-input" ) ; 
@@ -17,13 +17,17 @@ export class TodoList extends Component {
1717    } 
1818
1919    toggleState ( id )  { 
20-         this . state . todos [ id ] . isCompleted  =  ! this . state . todos [ id ] . isCompleted 
20+         this . state . todos [ id ] . isCompleted  =  ! this . state . todos [ id ] . isCompleted ; 
2121    } 
2222
2323    addTodo ( ev )  { 
2424        if  ( ev . keyCode  ===  13  &&  ev . target . value  !=  "" )  { 
2525            this . state . todos [ ++ this . state . lastId ]  =  { description : ev . target . value ,  isCompleted : false } ; 
26-             ev . target . value  =  "" 
26+             ev . target . value  =  "" ; 
2727        } 
2828    } 
29+ 
30+     removeTodo ( id )  { 
31+         delete  this . state . todos [ id ] ; 
32+     } 
2933} 
Original file line number Diff line number Diff line change 1111                    t-ref =" todo-input" 
1212                />
1313                <t  t-foreach =" Object.keys(this.state.todos)" t-as =" id" t-key =" id" 
14-                     <TodoItem  id =" id" todo =" this.state.todos[id]" " () => this.toggleState(id)" 
14+                     <TodoItem  
15+                         id =" id" 
16+                         todo =" this.state.todos[id]" 
17+                         toggleState.bind=" () => this.toggleState(id)" 
18+                         removeTodo.bind=" () => this.removeTodo(id)" 
19+                     />
1520                </t >
1621            </div >
1722        </div >
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments