Skip to content

Commit b73ff1c

Browse files
committed
[IMP] awesome_owl: add chapter 12 and missing ;s
1 parent 109d453 commit b73ff1c

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

awesome_owl/static/src/counter/counter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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});

awesome_owl/static/src/playground.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

awesome_owl/static/src/todo_list/todo_item.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

awesome_owl/static/src/todo_list/todo_item.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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>

awesome_owl/static/src/todo_list/todo_list.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { TodoItem } from "./todo_item";
33
import { useAutoFocus } from "../utils";
44

55
export 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
}

awesome_owl/static/src/todo_list/todo_list.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
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]" toggleState.bind="() => 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>

0 commit comments

Comments
 (0)