Skip to content

Commit ed77a5f

Browse files
committed
[IMP] awesome_dashboard: Created dashboard_item component
1 parent b18ac0b commit ed77a5f

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { Component } from "@odoo/owl";
44
import { registry } from "@web/core/registry";
55
import { Layout } from "@web/search/layout";
66
import { useService } from "@web/core/utils/hooks";
7+
import { DashboardItem } from "./dashboard_item/dashboard_item";
78

89
class AwesomeDashboard extends Component {
910
static template = "awesome_dashboard.AwesomeDashboard";
1011

1112
setup() {
1213
this.action = useService("action");
13-
//this.openSettings = this.openSettings.bind(this);
1414
}
1515
openCustomerList() {
1616
console.log('clicked');
@@ -21,7 +21,7 @@ class AwesomeDashboard extends Component {
2121
this.action.doAction("crm.crm_lead_all_leads");
2222
}
2323

24-
static components = { Layout };
24+
static components = { Layout, DashboardItem };
2525
}
2626

2727
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);

awesome_dashboard/static/src/dashboard.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
Leads
1414
</button>
1515
</t>
16+
<DashboardItem>
17+
Hello
18+
</DashboardItem>
19+
<DashboardItem size="2">
20+
Hello
21+
</DashboardItem>
22+
<DashboardItem>
23+
Hello
24+
</DashboardItem>
1625
</Layout>
1726
</t>
1827

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/** @odoo-module **/
2+
3+
import { Component } from "@odoo/owl";
4+
5+
export class DashboardItem extends Component {
6+
static template = "awesome_dashboard.DashboardItem";
7+
8+
setup() {
9+
this.width = this.props.size*18
10+
}
11+
12+
static defaultProps = {
13+
size: 1,
14+
};
15+
16+
static props = {
17+
size: {
18+
type: Number,
19+
optional: true,
20+
},
21+
slots: {
22+
default: Component
23+
}
24+
};
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_dashboard.DashboardItem">
5+
<div class="card d-inline-block m-2" t-attf-style="width: {{width}}rem;" >
6+
<div class="card-body">
7+
<h5 class="card-title">
8+
<t t-esc="props.title"/>
9+
</h5>
10+
<t t-slot="default"/>
11+
</div>
12+
</div>
13+
</t>
14+
15+
</templates>

0 commit comments

Comments
 (0)