Skip to content

Commit d91de1e

Browse files
committed
[IMP] awesome_dashboard: add generic dashboarditem to dashboard
1 parent 99bac3e commit d91de1e

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Component } from "@odoo/owl";
22
import { registry } from "@web/core/registry";
33
import { Layout } from "@web/search/layout";
44
import { useService } from "@web/core/utils/hooks";
5+
import { DashboardItem } from "./dashboarditem";
56

67
class AwesomeDashboard extends Component {
78
static template = "awesome_dashboard.AwesomeDashboard";
8-
static components = { Layout }
9+
static components = { Layout, DashboardItem };
910

1011
setup() {
1112
this.action = useService("action");
@@ -17,11 +18,11 @@ class AwesomeDashboard extends Component {
1718

1819
async openLeadsView() {
1920
this.action.doAction({
20-
type: 'ir.actions.act_window',
21-
name: ('Leads'),
22-
target: 'current',
23-
res_model: 'crm.lead',
24-
views: [[false, 'list'], [false, 'form']],
21+
type: "ir.actions.act_window",
22+
name: ("Leads"),
23+
target: "current",
24+
res_model: "crm.lead",
25+
views: [[false, "list"], [false, "form"]],
2526
});
2627
}
2728
}

awesome_dashboard/static/src/dashboard.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<t t-name="awesome_dashboard.AwesomeDashboard">
55
<button t-on-click="openCustomersView">Customers</button>
66
<button t-on-click="openLeadsView">Leads</button>
7-
<Layout display="{controlPanel: {} }" className="'o_dashboard h-100'">some content</Layout>
7+
<Layout display="{controlPanel: {} }" className="'o_dashboard h-100'">
8+
<DashboardItem>Card 1 Content</DashboardItem>
9+
<DashboardItem size="2">Card 2 Content</DashboardItem>
10+
</Layout>
811
</t>
912

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

awesome_owl/static/src/todolist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class TodoList extends Component {
99
setup() {
1010
this.state = useState({
1111
todos: [],
12-
idCounter: 0
12+
idCounter: 0,
1313
});
1414
useAutofocus("input_todo");
1515
};
@@ -18,7 +18,7 @@ export class TodoList extends Component {
1818
if (ev.keyCode === 13) {
1919
this.state.idCounter++
2020
this.state.todos.push({
21-
'id': this.state.idCounter, 'description': ev.target.value, 'isCompleted': false
21+
"id": this.state.idCounter, "description": ev.target.value, "isCompleted": false
2222
});
2323
ev.target.value = "";
2424
}

0 commit comments

Comments
 (0)