- hello world
+
+
+
+
+
+
+
+
The sum is:
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo_list/TodoItem.js b/awesome_owl/static/src/todo_list/TodoItem.js
new file mode 100644
index 00000000000..6610c4af1c4
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/TodoItem.js
@@ -0,0 +1,25 @@
+import { Component, useState} from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.todo_item";
+
+ static props = {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ toggleState: Function,
+ onRemove: Function
+ };
+
+ toggleTodo() {
+ if (this.props.toggleState) {
+ this.props.toggleState(this.props.id)
+ }
+ }
+
+ removeTodo() {
+ if (this.props.onRemove) {
+ this.props.onRemove(this.props.id)
+ }
+ }
+}
diff --git a/awesome_owl/static/src/todo_list/TodoList.js b/awesome_owl/static/src/todo_list/TodoList.js
new file mode 100644
index 00000000000..6c0a80ae087
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/TodoList.js
@@ -0,0 +1,55 @@
+import { Component, useState, useRef, onMounted } from "@odoo/owl";
+import { TodoItem } from "./TodoItem";
+import { useAutofocus} from "./../utils"
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todo_list";
+
+ static components = { TodoItem };
+
+ setup() {
+ this.todos = useState([ ]);
+ this.state = useState({
+ next_id: 1,
+ });
+ useAutofocus("input_todo");
+
+ }
+
+ onInputKeyup(ev) {
+ if (ev.key === "Enter") {
+ const value = ev.target.value.trim();
+ if (value) {
+ const next_id = this.state.next_id++;
+ this.todos.push(
+ {
+ id: next_id,
+ description: value,
+ isCompleted: false
+ }
+ )
+ ev.target.value = "";
+ }
+ }
+ }
+
+ toogleTodoState(id) {
+ if (!id) {
+ return;
+ }
+ const todo = this.todos.find(item => item.id === id);
+
+ if (!todo) {
+ return;
+ }
+ todo.isCompleted = !todo.isCompleted
+ }
+
+ removeTodo(id) {
+ const index = this.todos.findIndex((elem) => elem.id === id);
+ if (index >= 0) {
+ this.todos.splice(index, 1);
+ }
+ }
+
+}
diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml
new file mode 100644
index 00000000000..e967ed34e58
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ .
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml
new file mode 100644
index 00000000000..6c0a81dab9e
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..21689fd51e8
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,9 @@
+import { useRef, useEffect } from "@odoo/owl";
+
+export function useAutofocus(name) {
+ let ref = useRef(name);
+ useEffect(
+ (el) => el && el.focus(),
+ () => [ref.el]
+ );
+}