mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 09:32:22 +00:00
section 9
This commit is contained in:
parent
1b73b994ab
commit
48e91eba0e
|
@ -8,10 +8,17 @@ export class TodoList extends Component {
|
|||
static components = { TodoItem };
|
||||
|
||||
setup() {
|
||||
this.todos = useState([
|
||||
{id: 3, description: "buy milk", isCompleted: false },
|
||||
{ id: 1, description: "have a shower", isCompleted: true },
|
||||
{ id: 2, description: "sing loudly", isCompleted: false }
|
||||
]);
|
||||
this.todos = useState([]);
|
||||
}
|
||||
|
||||
addTodo(ev) {
|
||||
// If the key was enter and input isn't empty
|
||||
if(ev.keyCode === 13) {
|
||||
if(ev.target.value !== '') {
|
||||
// Let's create a todo
|
||||
this.todos.push({ id: this.todos.length+1, description: ev.target.value, isCompleted: false });
|
||||
ev.target.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="awesome_owl.todo_list">
|
||||
<p><input type="text" name="new-todo" placeholder="Add new todo" t-on-keyup="addTodo" /></p>
|
||||
<div class="d-inline-block border p-2 m-2">
|
||||
<t t-foreach="todos" t-as="todo" t-key="todo.id">
|
||||
<TodoItem todo="todo" />
|
||||
|
|
Loading…
Reference in a new issue