Skip to content

Commit 647c006

Browse files
committed
[ADD] awesome_dashboard: tasks 1-3
1 parent 5f3af82 commit 647c006

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
import { Component } 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 { _t } from "@web/core/l10n/translation";
6+
import { DashboardItem } from "./dashboard_item";
37

48
class AwesomeDashboard extends Component {
59
static template = "awesome_dashboard.AwesomeDashboard";
10+
static components = { Layout, DashboardItem };
11+
12+
setup() {
13+
this.action = useService("action");
14+
}
15+
16+
openCustomers() {
17+
this.action.doAction("base.action_partner_form")
18+
}
19+
20+
openLeads() {
21+
this.action.doAction({
22+
type: 'ir.actions.act_window',
23+
name: _t('CRM Leads'),
24+
target: 'current',
25+
res_model: 'crm.lead',
26+
views: [[false, 'list'],[false, 'form']],
27+
})
28+
}
29+
630
}
731

832
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.o_dashboard {
2+
background-color: slategrey;
3+
}

awesome_dashboard/static/src/dashboard.xml

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

44
<t t-name="awesome_dashboard.AwesomeDashboard">
5-
hello dashboard
5+
<Layout display="{controlPanel: {} }" className="'o_dashboard h-100'">
6+
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
7+
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
8+
<DashboardItem>
9+
<p>content 1</p>
10+
</DashboardItem>
11+
<DashboardItem size="2">
12+
<p>content 2</p>
13+
</DashboardItem>
14+
</Layout>
15+
616
</t>
717

818
</templates>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component } from "@odoo/owl";
2+
3+
export class DashboardItem extends Component {
4+
static template = "awesome_dashboard.DashboardItem";
5+
static props = {
6+
slots : {
7+
type: Object,
8+
optional: true
9+
},
10+
size : {
11+
type: Number,
12+
optional: true,
13+
},
14+
};
15+
static defaultProps = {
16+
size: 1,
17+
};
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 m-2" t-attf-style="width: {{18 * props.size }}rem;">
6+
<div class="card-body">
7+
<t t-slot="default"/>
8+
</div>
9+
</div>
10+
</t>
11+
12+
</templates>

0 commit comments

Comments
 (0)