mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 09:32:22 +00:00
stage 10
This commit is contained in:
parent
48e91eba0e
commit
840fa2d704
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import { Component, useState } from "@odoo/owl";
|
import { Component, useState } from "@odoo/owl";
|
||||||
import { TodoItem } from "./todo_item";
|
import { TodoItem } from "./todo_item";
|
||||||
|
import "../utils.js";
|
||||||
|
import { useAutofocus } from "../utils.js";
|
||||||
|
|
||||||
export class TodoList extends Component {
|
export class TodoList extends Component {
|
||||||
static template = "awesome_owl.todo_list";
|
static template = "awesome_owl.todo_list";
|
||||||
|
@ -9,6 +11,7 @@ export class TodoList extends Component {
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
this.todos = useState([]);
|
this.todos = useState([]);
|
||||||
|
useAutofocus('todo_input');
|
||||||
}
|
}
|
||||||
|
|
||||||
addTodo(ev) {
|
addTodo(ev) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<templates xml:space="preserve">
|
<templates xml:space="preserve">
|
||||||
<t t-name="awesome_owl.todo_list">
|
<t t-name="awesome_owl.todo_list">
|
||||||
<p><input type="text" name="new-todo" placeholder="Add new todo" t-on-keyup="addTodo" /></p>
|
<p><input t-ref="todo_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">
|
<div class="d-inline-block border p-2 m-2">
|
||||||
<t t-foreach="todos" t-as="todo" t-key="todo.id">
|
<t t-foreach="todos" t-as="todo" t-key="todo.id">
|
||||||
<TodoItem todo="todo" />
|
<TodoItem todo="todo" />
|
||||||
|
|
10
awesome_owl/static/src/utils.js
Normal file
10
awesome_owl/static/src/utils.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/** @odoo-module */
|
||||||
|
|
||||||
|
import { useRef, onMounted } from "@odoo/owl";
|
||||||
|
|
||||||
|
export function useAutofocus(name) {
|
||||||
|
const ref = useRef(name);
|
||||||
|
onMounted(() => {
|
||||||
|
ref.el.focus();
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue