Skip to content

Commit 5b2691c

Browse files
committed
Message to be changed, part of js 1.9
1 parent 8447731 commit 5b2691c

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

awesome_owl/static/src/todolist/todolist.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@ export class TodoList extends Component {
77
static components = { TodoItem };
88

99
setup() {
10-
this.todos = useState([
11-
{ id: 3, description: "buy milk", isCompleted: false },
12-
{ id: 4, description: "Go to work", isCompleted: true },
13-
14-
]);
10+
this.todos = useState([]);
1511
}
1612

17-
}
13+
addTodo(ev) {
14+
if (ev.keyCode === 13) {
15+
16+
console.debug(this.todos);
17+
console.debug(this.todos.length);
18+
var todoId;
19+
if (this.todos.length == 0) {
20+
todoId = 0;
21+
} else {
22+
todoId = this.todos[-1].id + 1;
23+
}
24+
this.todos.push({ id: todoId, description: x, isCompleted: false })
25+
}
26+
console.debug(ev.keyCode)
27+
}
28+
}

awesome_owl/static/src/todolist/todolist.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<t t-name="awesome_owl.todolist">
55
<div class="card d-inline-block m-2">
6+
<input placeholder="Enter a new task" t-on-keyup="ev => this.addTodo(ev)"/>
67
<t t-foreach="todos" t-as="i" t-key="i.id">
78
<TodoItem todo="i"/>
89
</t>

0 commit comments

Comments
 (0)