Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8242913
[ADD] todo: add new todo, card and counter components
macocianradu Sep 23, 2025
b57ecf4
[IMP] todo: Focusing the input
macocianradu Sep 23, 2025
2d3beff
[IMP] todo: deleting todos
macocianradu Sep 23, 2025
0c74508
[IMP] awesome_owl: generic card with slots
macocianradu Sep 23, 2025
9cc166e
[IMP] awesome_owl: minimizing card content
macocianradu Sep 23, 2025
8ae5640
[IMP] awesome_dashboard: add some buttons for quick navigation
macocianradu Sep 23, 2025
3c99f45
[IMP] awesome_dashboard: add a dashboard item
macocianradu Sep 23, 2025
2726b2e
[IMP] awesome_dashboard: call the server, add some statistics
macocianradu Sep 23, 2025
0134803
[IMP] awesome_dashboard: cache network calls, create a service
macocianradu Sep 23, 2025
4346a21
[IMP] awesome_dashboard: display a pie chart
macocianradu Sep 24, 2025
a5fa22a
[IMP] awesome_dashboard: real life update
macocianradu Sep 24, 2025
abddaa5
[IMP] awesome_dashboard: lazy loading the dashboard
macocianradu Sep 24, 2025
3416192
[IMP] awesome_dashboard: making the dashboard extensible
macocianradu Sep 24, 2025
6e53f4b
[IMP] awesome_dashboard: make the dashboard extensible
macocianradu Sep 24, 2025
0df9683
[IMP] awesome_dashboard: add and remove dashboard items
macocianradu Sep 24, 2025
9842f55
[IMP] awesome_dashboard: add translations to text
macocianradu Sep 24, 2025
bce86ab
[FIX] awesome_dashboard: run prettier
macocianradu Sep 24, 2025
9a06420
[IMP] awesome_dashboard: opening orders on chart click
macocianradu Sep 25, 2025
abe7d49
[IMP] awesome_dashboard: make cards reactive on mobile
macocianradu Sep 25, 2025
df6646a
[IMP] awesome_dashboard: saving dashboard in config_properties
macocianradu Sep 25, 2025
f81a9cd
[IMP] awesome_dashboard: adding a controller action for user settings
macocianradu Sep 26, 2025
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
21 changes: 21 additions & 0 deletions awesome_dashboard/static/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout };

setup() {
this.action = useService("action");
}

openCustomers() {
this.action.doAction('base.action_partner_form')
}

openLeads() {
this.action.doAction({
type: 'ir.actions.act_window',
name: _t('Leads'),
res_model: 'crm.lead',
views: [[false, 'list'], [false, 'form']]
})
}
}

registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard {
background-color: gray;
}
7 changes: 6 additions & 1 deletion awesome_dashboard/static/src/dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<Layout display="{ controlPanel: {} }" className="'o_dashboard h-100'">
<t t-set-slot='layout-buttons'>
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
</t>
</Layout>
</t>

</templates>
15 changes: 15 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, useState } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.card";

static props = ['title', 'slots']

setup() {
this.state = useState({ hidden: false })
}

hide() {
this.state.hidden = !this.state.hidden
}
}
16 changes: 16 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.card">
<div class="card m-2">
<div class="card-body">
<h5 class="card-title d-inline-flex justify-content-between w-100">
<t t-esc="props.title"/>
<span class="fa fa-remove" t-on-click="hide"/>
</h5>
<t t-slot="default" t-if="!this.state.hidden">
</t>
</div>
</div>
</t>
</templates>
21 changes: 21 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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();
}
}
}
10 changes: 10 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.counter">
<div class="d-inline-flex m-2 p-2 border border-2 border-dark">
<p>Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</div>
</t>
</templates>
22 changes: 21 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
/** @odoo-module **/

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 "./todo/todo_list";

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

setup() {
this.state = useState({sum: 2})
}

incrementSum() {
console.log('call')
this.state.sum++
}

card_body = markup(`
<span class="text-secondary">
content of card <b>2</b>
</span>
`);
}

23 changes: 20 additions & 3 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<div class="p-4">
<div >
Hi
<Counter onChange.bind="incrementSum"/>
<Counter onChange.bind="incrementSum"/>
</div>
<div class="m-2 d-inline-flex border border-1 border-dark">
<Card title="'card 1'">
<p>Content of card 1</p>
</Card>
<Card title="'card 2'" >
<span class="text-secondary">
content of card <b>2</b>
</span>
</Card>
</div>
<p>Sum: <t t-esc="state.sum"/> </p>
<Card title="'Todos'">
<TodoList />
</Card>
</div>
</t>

</templates>
10 changes: 10 additions & 0 deletions awesome_owl/static/src/todo/todo.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🥇

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export class Todo {
id
description
isCompleted
constructor(id, description, isCompleted) {
this.id = id
this.description = description;
this.isCompleted = isCompleted;
}
}
18 changes: 18 additions & 0 deletions awesome_owl/static/src/todo/todo_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from "@odoo/owl";
import { Todo } from "./todo";
import { Card } from "../card/card";

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

static props = { todo: { type: Todo }, onRemove: { type: Function } }

toggle() {
this.props.todo.isCompleted = !this.props.todo.isCompleted;
}

remove() {
this.props.onRemove(this.props.todo.id)
}
}
19 changes: 19 additions & 0 deletions awesome_owl/static/src/todo/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.todo_item">
<div class="d-inline-flex" t-on-click="toggle">
<p
class="me-4"
t-esc="this.props.todo.description"
t-att-class="{'text-muted text-decoration-line-through': this.props.todo.isCompleted}" />
<t t-if="this.props.todo.isCompleted" class="mx-2">
</t>
<t t-if="!this.props.todo.isCompleted" class="mx-2">
🔄
</t>
<span class="fa fa-remove mx-4" t-on-click="remove"/>
</div>
</t>
</templates>
31 changes: 31 additions & 0 deletions awesome_owl/static/src/todo/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "./todo_item";
import { Todo } from "./todo";
import { Card } from "../card/card";
import { useAutofocus } from "../utils";

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

ids = 0

setup() {
this.state = useState({ todos: [], input: '' })
useAutofocus('todo_input')
}

keyup(event) {
if (event.keyCode === 13) {
this.state.todos.push(new Todo(this.ids++, event.srcElement.value, false))
}
}

remove(id) {
const index = this.state.todos.findIndex((elem) => elem.id === id)
if (index >= 0) {
this.state.todos.splice(index, 1)
}
}
}

12 changes: 12 additions & 0 deletions awesome_owl/static/src/todo/todo_list.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.todo_list">
<div class="d-flex flex-column card p-2 w-25">
<h5> Todos </h5>
<input type="text" t-on-keyup="keyup" t-ref="todo_input" />
<t t-foreach="this.state.todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" onRemove.bind="remove" />
</t>
</div>
</t>
</templates>
8 changes: 8 additions & 0 deletions awesome_owl/static/src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useRef, onMounted } from "@odoo/owl"

export function useAutofocus(name) {
let ref = useRef(name)
onMounted(() => {
ref.el.focus()
})
}