From 7f28d797c91b1b6e723bee69618055bad9208c59 Mon Sep 17 00:00:00 2001 From: Matt Marcha Date: Fri, 27 Sep 2024 12:14:22 -1000 Subject: [PATCH] ch2.10 make it extensible --- awesome_dashboard/static/src/dashboard/dashboard.js | 2 +- .../static/src/dashboard/dashboard_items.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 9a4370b..8c8a866 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -20,7 +20,7 @@ class AwesomeDashboard extends Component { this.stats = useState(useService('awesome_dashboard.statistics')); - this.items = items; + this.items = registry.category("awesome_dashboard").getAll(); } openCustomers() { diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js index 224d57b..556005b 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_items.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -1,7 +1,9 @@ /** @odoo-module */ import { NumberCard } from "./number_card/number_card"; import { PieChartCard } from "./pie_chart_card/pie_chart_card"; -export const items = [ +import { registry } from "@web/core/registry"; + +const items = [ { id: "average_quantity", description: "Average amount of t-shirt", @@ -57,4 +59,9 @@ export const items = [ values: data.orders_by_size, }) } -] \ No newline at end of file + +] + +items.forEach(item => { + registry.category("awesome_dashboard").add(item.id, item); +}); \ No newline at end of file