-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[IMP] awesomeclicker: add editor metadata in Python file #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 19.0
Are you sure you want to change the base?
Changes from all commits
9a8f241
169daed
aa17f8b
e44c44e
7b475b6
8b7b934
1b855f7
e30a69a
4508a76
71d9a81
2cc58a4
9b65e0a
a2af77e
c0cc56a
1fc90ff
98b250c
3304ef2
3028c94
dffa3b2
e205ffa
3b255e1
f7c72e6
7b20935
baeca0a
7c23553
3b625a7
65b7c35
1c84d45
5fe6e52
06b7abd
3293cbc
c5e2e5c
6304f12
8b8b108
4ac34d7
a513edc
173ddac
d05103d
ed4ed74
4f5dce2
65c7bc2
bc8312e
d296649
ce585d6
4b4f0bb
be259d0
483bd50
08f9b67
df82d76
492ac07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers | ||
| from . import controllers |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
| import { useService } from "@web/core/utils/hooks"; | ||
| import { statisticsStore } from "./services/statistics_service"; | ||
| import { DashboardItem } from "./dashboard_item"; | ||
| import { dashboardItemRegistry } from "./dashboard_registry"; | ||
| import { DashboardSettingsDialog } from "./dashboard_settings_dialog"; | ||
|
|
||
| export class AwesomeDashboard extends Component { | ||
| static template = "awesome_dashboard.AwesomeDashboard"; | ||
| static components = { DashboardItem }; | ||
|
|
||
| static props = { | ||
| onSettingsOpen: Function, // callback to expose settings API | ||
| }; | ||
|
|
||
| setup() { | ||
| this.dialog = useService("dialog"); | ||
| this.stats = useState(statisticsStore); | ||
|
|
||
| this.allItems = dashboardItemRegistry.getAll(); | ||
|
|
||
| // reactive items | ||
| this.state = useState({ | ||
| items: this.getFilteredItems(), | ||
| }); | ||
|
|
||
| // expose the API | ||
| if (this.props.onSettingsOpen) { | ||
| this.props.onSettingsOpen(() => this.openSettings()); | ||
| } | ||
| } | ||
|
|
||
| getFilteredItems() { | ||
| const removed = JSON.parse( | ||
| localStorage.getItem("awesome_dashboard.removed_items") || "[]" | ||
| ); | ||
| return this.allItems.filter(item => !removed.includes(item.id)); | ||
| } | ||
|
|
||
| openSettings() { | ||
| this.dialog.add(DashboardSettingsDialog, { | ||
| items: this.allItems, | ||
| onApply: () => { | ||
| this.state.items = this.getFilteredItems(); | ||
| }, | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| import { Component } from "@odoo/owl"; | ||||||
| import { Layout } from "@web/search/layout"; | ||||||
| import { AwesomeDashboard } from "./awesome_dashboard"; | ||||||
| import { registry } from "@web/core/registry"; | ||||||
|
|
||||||
| export class AwesomeDashboardWrapper extends Component { | ||||||
| static template = "awesome_dashboard.AwesomeDashboardWrapper"; | ||||||
| static components = { Layout, AwesomeDashboard }; | ||||||
|
|
||||||
| setup() { | ||||||
| this.action = this.env.services.action; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| this.dashboardOpenSettings = null; | ||||||
|
|
||||||
| this.setDashboardSettingsCallback = (fn) => { | ||||||
| this.dashboardOpenSettings = fn; | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| openSettings() { | ||||||
| if (this.dashboardOpenSettings) { | ||||||
| this.dashboardOpenSettings(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| openCustomers() { | ||||||
| this.action.doAction("base.action_partner_form"); | ||||||
| } | ||||||
|
|
||||||
| openLeads() { | ||||||
| this.action.doAction({ | ||||||
| type: "ir.actions.act_window", | ||||||
| name: "Leads", | ||||||
| res_model: "crm.lead", | ||||||
| views: [[false, "list"], [false, "form"]], | ||||||
| target: "current", | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| get layoutProps() { | ||||||
| return { display: { controlPanel: {}, className: "o_dashboard h-100" } }; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Register for lazy loading | ||||||
| registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboardWrapper); | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .o_dashboard { | ||
| background-color: grey; | ||
| } | ||
|
|
||
| .o_dashboard .card { | ||
| border-radius: 12px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
| export class DashboardItem extends Component { | ||
| static template = "awesome_dashboard.DashboardItem"; | ||
|
|
||
| // Default value | ||
| static defaultProps = { | ||
| size: 1, // if parent doesn't provide `size`, it will be 1 | ||
| }; | ||
|
|
||
| static props = { | ||
| size: { type: Number, optional: true }, | ||
| }; | ||
|
|
||
| get width() { | ||
| return `width: ${18 * this.props.size}rem`; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { dashboardItemRegistry } from "./dashboard_registry"; | ||
| import { NumberCard } from "./number_card"; | ||
| import { PieChartCard } from "./pie_chart_card"; | ||
|
|
||
| dashboardItemRegistry.add("new_orders", { | ||
| id: "new_orders", | ||
| description: "New orders this month", | ||
| Component: NumberCard, | ||
| props: (stats) => ({ | ||
| title: "New Orders", | ||
| value: stats.nb_new_orders, | ||
| }), | ||
| }); | ||
|
|
||
| dashboardItemRegistry.add("total_amount", { | ||
| id: "total_amount", | ||
| description: "Total amount this month", | ||
| Component: NumberCard, | ||
| props: (stats) => ({ | ||
| title: "Total Amount", | ||
| value: stats.total_amount, | ||
| }), | ||
| }); | ||
|
|
||
| dashboardItemRegistry.add("average_quantity", { | ||
| id: "average_quantity", | ||
| description: "Average T-Shirts per order", | ||
| Component: NumberCard, | ||
| props: (stats) => ({ | ||
| title: "Avg T-Shirts / Order", | ||
| value: stats.average_quantity, | ||
| }), | ||
| }); | ||
|
|
||
| dashboardItemRegistry.add("cancelled_orders", { | ||
| id: "cancelled_orders", | ||
| description: "Cancelled orders this month", | ||
| Component: NumberCard, | ||
| props: (stats) => ({ | ||
| title: "Cancelled Orders", | ||
| value: stats.nb_cancelled_orders, | ||
| }), | ||
| }); | ||
|
|
||
| dashboardItemRegistry.add("avg_time", { | ||
| id: "avg_time", | ||
| description: "Average processing time", | ||
| Component: NumberCard, | ||
| size: 2, | ||
| props: (stats) => ({ | ||
| title: "Avg Processing Time (hours)", | ||
| value: stats.average_time, | ||
| }), | ||
| }); | ||
|
|
||
| dashboardItemRegistry.add("tshirt_sizes", { | ||
| id: "tshirt_sizes", | ||
| description: "T-Shirt sizes sold", | ||
| Component: PieChartCard, | ||
| size: 2, | ||
| props: (stats) => ({ | ||
| title: "T-Shirt Sizes Sold", | ||
| data: stats.orders_by_size, | ||
| }), | ||
| }); |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can include this in the |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { registry } from "@web/core/registry"; | ||
|
|
||
| // Create a new registry category for dashboard items | ||
| export const dashboardItemRegistry = registry.category("awesome_dashboard.items"); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this :) By the way, XML and JS files don't need to be in separate folders. If you want, you can create one folder per component (e.g. move both
pie_chart.xmlandpie_chart.jsinto apie_chart/folder), but it's better to have the XML and JS files of the same component next to each other.