ch2.3 Add a dashboard item

This commit is contained in:
Matt Marcha 2024-09-20 12:20:35 -10:00
parent ef7fb887b7
commit c0f193b52c
4 changed files with 41 additions and 1 deletions

View file

@ -4,10 +4,11 @@ import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout"; import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks" import { useService } from "@web/core/utils/hooks"
import { DashboardItem } from "./dashboard_item";
class AwesomeDashboard extends Component { class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard"; static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout }; static components = { Layout, DashboardItem };
setup() { setup() {
this.display = { this.display = {

View file

@ -7,6 +7,11 @@
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button> <button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
<button class="btn btn-primary" t-on-click="openLeads">Leads</button> <button class="btn btn-primary" t-on-click="openLeads">Leads</button>
</t> </t>
<div class="d-flex flex-wrap">
<DashboardItem />
<DashboardItem size="2">That's a bigger one</DashboardItem>
<DashboardItem/>
</div>
</Layout> </Layout>
</t> </t>

View file

@ -0,0 +1,20 @@
/** @odoo-module **/
import { Component } from "@odoo/owl";
export class DashboardItem extends Component {
static template = "awesome_dashboard.DashboardItem";
static props = {
size: {
type: Number,
default: 1,
optional: true,
},
slots: {
type: Object,
shape: {
default: Object
},
}
};
}

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardItem">
<section>
<div class="card d-inline-block m-2" t-attf-style="width:{{18*props.size}}rem;">
<div class="card-body">
<t t-slot="default">some content</t>
</div>
</div>
</section>
</t>
</templates>