Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awesome_dashboard/controllers/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)

class AwesomeDashboard(http.Controller):
@http.route('/awesome_dashboard/statistics', type='json', auth='user')
@http.route('/awesome_dashboard/statistics', type='jsonrpc', auth='user')
def get_statistics(self):
"""
Returns a dict of statistics about the orders:
Expand Down
11 changes: 11 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.card";
static props = {
title: { type: String },
content: { type: String },
};
}
14 changes: 14 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<templates xml:space="preserve">
<t t-name="awesome_owl.card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">
<t t-esc="props.title"/>
</h5>
<p class="card-text">
<t t-out="props.content"/>
</p>
</div>
</div>
</t>
</templates>
17 changes: 17 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component, useState } from "@odoo/owl";

export class Counter extends Component {
static template = "awesome_owl.counter";
static props = { onChange: { type: Function, optional: true }};

setup() {
this.state = useState({ value: 1 });
}

increment() {
this.state.value++;
if (this.props.onChange) {
this.props.onChange();
}
}
}
12 changes: 12 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.counter">
<div class="p-3">
hello world
<p>Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</div>
</t>

</templates>
16 changes: 15 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { Component } from "@odoo/owl";
import { Component, markup, useState} from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todolist/todolist";

export class Playground extends Component {
static template = "awesome_owl.playground";
static components = { Counter, Card, TodoList };

setup(){
this.htmlNormal = "<div class='text-primary'>some content</div>";
this.htmlMarkup = markup("<div class='text-primary'>some content</div>");
this.state = useState({ sum: 2 });
}

incrementSum() {
this.state.sum++;
}
}
15 changes: 15 additions & 0 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<div class="d-flex justify-content-around">
<Counter onChange="() => this.incrementSum()"/>
<Counter onChange="() => this.incrementSum()"/>
</div>
<div class="alert alert-info d-inline-block fw-bold fs-4">
The sum is: <t t-esc="state.sum"/>
</div>
</div>
<div>
<Card title="'card 1'" content="htmlNormal"/>
<Card title="'card 2'" content="htmlMarkup"/>
</div>
<hr/>
<div class="mt-4">
<TodoList/>
</div>
</t>

Expand Down
15 changes: 15 additions & 0 deletions awesome_owl/static/src/todolist/todo_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from "@odoo/owl";

export class TodoItem extends Component {
static template = "awesome_owl.TodoItem";
static props = {
todo: {
type: Object,
shape: {
id: Number,
description: String,
isCompleted: Boolean,
},
},
};
}
9 changes: 9 additions & 0 deletions awesome_owl/static/src/todolist/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoItem">
<div t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}">
<span class="badge bg-secondary"># <t t-esc="props.todo.id"/></span>
<span class="text-dark"><t t-esc="props.todo.description"/></span>
</div>
</t>
</templates>
29 changes: 29 additions & 0 deletions awesome_owl/static/src/todolist/todolist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "./todo_item";

export class TodoList extends Component {
static template = "awesome_owl.TodoList";
static components = { TodoItem };

setup() {
this.todos = useState([]);
}

addTodo(ev) {
if (ev.keyCode === 13) {
const description = ev.target.value.trim();

if (!description) {
return;
}

this.todos.push({
id: this.nextId++,
description: description,
isCompleted: false,
});

ev.target.value = "";
}
}
}
17 changes: 17 additions & 0 deletions awesome_owl/static/src/todolist/todolist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoList">
<div class="p-3 border rounded bg-white text-start" style="max-width: 400px;">
<h4 class="text-primary mb-3">My Todo List</h4>
<div class="mb-3">
<input type="text"
class="form-control"
placeholder="Add a todo"
t-on-keyup="addTodo"/>
</div>
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo"/>
</t>
</div>
</t>
</templates>