Skip to content

Commit 0f8a0c9

Browse files
committed
[IMP] awesome_owl: add counter, card components and todo lists
-Made estate module user-friendly UI -Added counter and card component and display in awesome owl module -Added todo list in awesome_owl
1 parent 0e2371c commit 0f8a0c9

File tree

22 files changed

+275
-14
lines changed

22 files changed

+275
-14
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from . import controllers
1+
from . import controllers

awesome_dashboard/controllers/controllers.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import logging
42
import random
53

@@ -33,4 +31,3 @@ def get_statistics(self):
3331
},
3432
'total_amount': random.randint(100, 1000)
3533
}
36-
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Component } from "@odoo/owl";
1+
import { Component, onWillStart } from "@odoo/owl";
22
import { registry } from "@web/core/registry";
3+
import { Layout } from "@web/search/layout";
4+
import { useService } from "@web/core/utils/hooks";
5+
import { DashboardItem } from "./dashboard_item/dashboard_item";
36

47
class AwesomeDashboard extends Component {
58
static template = "awesome_dashboard.AwesomeDashboard";
69
}
710

8-
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
11+
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);

awesome_dashboard/static/src/dashboard.xml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,44 @@
22
<templates xml:space="preserve">
33

44
<t t-name="awesome_dashboard.AwesomeDashboard">
5-
hello dashboard
5+
<Layout display="display" className="'o_dashboard h-100'">
6+
<t t-set-slot="layout-buttons">
7+
<button class="btn btn-primary" t-on-click="openCustomerView">Customers</button>
8+
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
9+
</t>
10+
<div class="d-flex flex-wrap">
11+
<DashboardItem>
12+
Average amount of t-shirt by order this month
13+
<div class="fs-1 fw-bold text-success text-center">
14+
<t t-esc="statistics.average_quantity"/>
15+
</div>
16+
</DashboardItem>
17+
<DashboardItem>
18+
Average time for an order to go from 'new' to 'sent' or 'cancelled'
19+
<div class="fs-1 fw-bold text-success text-center">
20+
<t t-esc="statistics.average_time"/>
21+
</div>
22+
</DashboardItem>
23+
<DashboardItem>
24+
Number of new orders this month
25+
<div class="fs-1 fw-bold text-success text-center">
26+
<t t-esc="statistics.nb_new_orders"/>
27+
</div>
28+
</DashboardItem>
29+
<DashboardItem>
30+
Number of cancelled orders this month
31+
<div class="fs-1 fw-bold text-success text-center">
32+
<t t-esc="statistics.nb_cancelled_orders"/>
33+
</div>
34+
</DashboardItem>
35+
<DashboardItem>
36+
Total amount of new orders this month
37+
<div class="fs-1 fw-bold text-success text-center">
38+
<t t-esc="statistics.total_amount"/>
39+
</div>
40+
</DashboardItem>
41+
</div>
42+
</Layout>
643
</t>
744

845
</templates>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component, useState } from "@odoo/owl";
2+
3+
export class Card extends Component {
4+
static template = "awesome_owl.Card";
5+
static props = {
6+
title: String,
7+
slots: {
8+
type: Object,
9+
shape: {
10+
default: true
11+
},
12+
}
13+
};
14+
15+
setup() {
16+
this.state = useState({ isOpen: true });
17+
}
18+
19+
toggleContent() {
20+
this.state.isOpen = !this.state.isOpen;
21+
}
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.Card">
4+
<div class="card d-inline-block m-2" style="width: 18rem;">
5+
<div class="card-body">
6+
<h5 class="card-title">
7+
<t t-out="props.title"/>
8+
<button class="btn" t-on-click="toggleContent">Toggle</button>
9+
</h5>
10+
<p class="card-text" t-if="state.isOpen">
11+
<t t-slot="default"/>
12+
</p>
13+
</div>
14+
</div>
15+
</t>
16+
</templates>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, useState } from "@odoo/owl";
2+
3+
export class Counter extends Component {
4+
static template = "awesome_owl.Counter";
5+
static props = {
6+
onChange: { type: Function, optional: true }
7+
};
8+
9+
setup() {
10+
this.state = useState({ value: 1 });
11+
}
12+
13+
increment() {
14+
this.state.value = this.state.value + 1;
15+
if (this.props.onChange) {
16+
this.props.onChange();
17+
}
18+
}
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.Counter">
4+
<div class="m-2 p-2 border d-inline-block">
5+
<span class="me-2">Counter: <t t-esc="state.value"/></span>
6+
<button class="btn btn-primary" t-on-click="increment">Increment</button>
7+
</div>
8+
</t>
9+
</templates>

awesome_owl/static/src/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ const config = {
99

1010
// Mount the Playground component when the document.body is ready
1111
whenReady(() => mountComponent(Playground, document.body, config));
12-
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
import { Component } from "@odoo/owl";
1+
import { Component, markup, useState } from "@odoo/owl";
2+
import { Counter } from "./counter/counter";
3+
import { Card } from "./card/card";
4+
import { TodoList } from "./todo_list/todo_list";
25

36
export class Playground extends Component {
47
static template = "awesome_owl.playground";
8+
static components = { Counter, Card, TodoList };
9+
10+
setup() {
11+
this.str1 = "<div class='text-primary'>some content</div>";
12+
this.str2 = markup("<div class='text-primary'>some content</div>");
13+
this.sum = useState({ value: 2 });
14+
}
15+
16+
incrementSum() {
17+
this.sum.value++;
18+
}
519
}

0 commit comments

Comments
 (0)