mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 17:42:22 +00:00
Compare commits
No commits in common. "5ebc65e0966cc9f8699f670b6531c682ed73245a" and "38c8de380400fc8b1940762b84487826ca87434d" have entirely different histories.
5ebc65e096
...
38c8de3804
|
@ -4,21 +4,5 @@ import { Component, useState } from "@odoo/owl";
|
||||||
|
|
||||||
export class Card extends Component {
|
export class Card extends Component {
|
||||||
static template = "awesome_owl.card";
|
static template = "awesome_owl.card";
|
||||||
static props = {
|
static props = ['title', 'content'];
|
||||||
title: String,
|
|
||||||
slots: {
|
|
||||||
type: Object,
|
|
||||||
shape: {
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
this.toggle = useState({isOpen: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleContent() {
|
|
||||||
this.toggle.isOpen = !this.toggle.isOpen;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,12 +5,9 @@
|
||||||
<section>
|
<section>
|
||||||
<div class="card d-inline-block m-2" style="width: 18rem;">
|
<div class="card d-inline-block m-2" style="width: 18rem;">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title"><t t-esc="props.title"/></h3>
|
||||||
<t t-out="props.title"/>
|
<p class="card-text">
|
||||||
<button class="btn" t-on-click="toggleContent">Toggle</button>
|
<t t-esc="props.content"/>
|
||||||
</h3>
|
|
||||||
<p class="card-text" t-if="toggle.isOpen">
|
|
||||||
<t t-slot="default"/>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,12 +6,8 @@
|
||||||
<Counter onChange.bind="incrementSum"/>
|
<Counter onChange.bind="incrementSum"/>
|
||||||
<p>The sum is <t t-esc="sum.value"/></p>
|
<p>The sum is <t t-esc="sum.value"/></p>
|
||||||
<hr />
|
<hr />
|
||||||
<Card title="'Card 1'">
|
<Card title="'Card 1'" content="'This is the awesome content of the card 1'" />
|
||||||
<span>Hello Owl</span>
|
<Card title="'Card, the 2nd'" content="'Here is another card content. It is the second one.'" />
|
||||||
</Card>
|
|
||||||
<Card title="'Card, the 2nd'">
|
|
||||||
<Counter />
|
|
||||||
</Card>
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<TodoList />
|
<TodoList />
|
||||||
</t>
|
</t>
|
||||||
|
|
|
@ -10,14 +10,9 @@ export class TodoItem extends Component {
|
||||||
shape: { id: Number, description: String, isCompleted: Boolean }
|
shape: { id: Number, description: String, isCompleted: Boolean }
|
||||||
},
|
},
|
||||||
onToggle: Function,
|
onToggle: Function,
|
||||||
removeTodo: Function,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.props.onToggle(this.props.todo.id);
|
this.props.onToggle(this.props.todo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
|
||||||
this.props.removeTodo(this.props.todo.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@
|
||||||
<t t-esc="props.todo.id"/>.
|
<t t-esc="props.todo.id"/>.
|
||||||
<t t-esc="props.todo.description"/>
|
<t t-esc="props.todo.description"/>
|
||||||
</label>
|
</label>
|
||||||
<span class="fa fa-remove" t-on-click="remove"/>
|
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
|
@ -10,7 +10,6 @@ export class TodoList extends Component {
|
||||||
static components = { TodoItem };
|
static components = { TodoItem };
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
this.todoCounter = 1;
|
|
||||||
this.todos = useState([]);
|
this.todos = useState([]);
|
||||||
useAutofocus('todo_input');
|
useAutofocus('todo_input');
|
||||||
}
|
}
|
||||||
|
@ -20,7 +19,7 @@ export class TodoList extends Component {
|
||||||
if(ev.keyCode === 13) {
|
if(ev.keyCode === 13) {
|
||||||
if(ev.target.value !== '') {
|
if(ev.target.value !== '') {
|
||||||
// Let's create a todo
|
// Let's create a todo
|
||||||
this.todos.push({ id: this.todoCounter++, description: ev.target.value, isCompleted: false });
|
this.todos.push({ id: this.todos.length+1, description: ev.target.value, isCompleted: false });
|
||||||
ev.target.value = '';
|
ev.target.value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +31,4 @@ export class TodoList extends Component {
|
||||||
todo.isCompleted = !todo.isCompleted;
|
todo.isCompleted = !todo.isCompleted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeItem(id) {
|
|
||||||
const todoIndex = this.todos.findIndex((obj) => obj.id === id);
|
|
||||||
if (todoIndex >= 0) {
|
|
||||||
this.todos.splice(todoIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
<p><input t-ref="todo_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" onToggle.bind="toggleState" removeTodo.bind="removeItem"/>
|
<TodoItem todo="todo" onToggle.bind="toggleState"/>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
Loading…
Reference in a new issue