Skip to content

Commit 0b06b0e

Browse files
committed
[IMP] awesome_dashboard: Init dialog
1 parent eadf4c3 commit 0b06b0e

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Component } from "@odoo/owl";
2+
import { CheckBox } from "@web/core/checkbox/checkbox";
3+
import { Dialog } from "@web/core/dialog/dialog";
4+
import { registry } from "@web/core/registry";
5+
import dashboard_items from "../dashboard_items";
6+
7+
export class ConfigurationDialog extends Component {
8+
static template = "awesome_dashboard.ConfigurationDialog";
9+
static components = { CheckBox, Dialog };
10+
static props = { close };
11+
12+
setup() {
13+
this.items = registry.category("awesome_dashboard").getAll();
14+
}
15+
16+
onChange(item, value) {
17+
localStorage.setItem("", {});
18+
}
19+
20+
onClose() {
21+
this.props.close();
22+
}
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_dashboard.ConfigurationDialog">
5+
<Dialog
6+
size="'md'"
7+
title="'Dashboard items configuration'"
8+
>
9+
<p>Which cards do you wish to see?</p>
10+
<t t-foreach="items" t-as="item" t-key="item.id">
11+
<CheckBox
12+
name="'enabled'"
13+
value="false"
14+
>
15+
<t t-esc="item.description"/>
16+
</CheckBox>
17+
</t>
18+
<t t-set-slot="footer">
19+
<button class="btn btn-primary" t-on-click="onClose">
20+
Apply
21+
</button>
22+
</t>
23+
</Dialog>
24+
</t>
25+
26+
</templates>

awesome_dashboard/static/src/dashboard/dashboard.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useService } from "@web/core/utils/hooks";
44
import { Layout } from "@web/search/layout";
55
import { DashboardItem } from "./dashboard_item/dashboard_item";
66
import { PieChart } from "./pie_chart/pie_chart";
7+
import { ConfigurationDialog } from "./configuration_dialog/configuration_dialog";
78
import dashboard_items from "./dashboard_items";
89

910
class AwesomeDashboard extends Component {
@@ -14,6 +15,7 @@ class AwesomeDashboard extends Component {
1415
this.action = useService("action");
1516
this.state = reactive({ statistics: useService("statistics") });
1617
this.items = registry.category("awesome_dashboard").getAll();
18+
this.dialog = useService("dialog");
1719
}
1820

1921
openLeads() {
@@ -31,6 +33,13 @@ class AwesomeDashboard extends Component {
3133
openCustomers() {
3234
this.action.doAction("base.action_partner_form");
3335
}
36+
37+
openConfiguration() {
38+
this.dialog.add(
39+
ConfigurationDialog,
40+
{},
41+
);
42+
}
3443
}
3544

3645
registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);

awesome_dashboard/static/src/dashboard/dashboard.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
Leads
1515
</button>
1616
</t>
17+
<t t-set-slot="control-panel-additional-actions">
18+
<button t-on-click="openConfiguration" class="btn">
19+
<i class="fa fa-cog"/>
20+
</button>
21+
</t>
1722
<div class="d-flex align-items-start flex-wrap">
1823
<t t-foreach="items" t-as="item" t-key="item.id">
1924
<DashboardItem size="item.size || 1">

0 commit comments

Comments
 (0)