mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_refresher: Provide the ability to reload information from a report view
This commit is contained in:
9
web_refresher/static/src/js/control_panel.esm.js
Normal file
9
web_refresher/static/src/js/control_panel.esm.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @odoo-module **/
|
||||
/* Copyright 2024 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
import {ControlPanel} from "@web/search/control_panel/control_panel";
|
||||
import {Refresher} from "./refresher.esm";
|
||||
|
||||
ControlPanel.components = Object.assign({}, ControlPanel.components, {
|
||||
Refresher,
|
||||
});
|
||||
@@ -4,12 +4,32 @@
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
||||
const {Component} = owl;
|
||||
import {useService} from "@web/core/utils/hooks";
|
||||
|
||||
export class Refresher extends Component {
|
||||
_doRefresh() {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.action = useService("action");
|
||||
}
|
||||
async _doRefresh() {
|
||||
const viewAction = this.action.currentController.action;
|
||||
// Allow refresh reports
|
||||
if (["ir.actions.report", "ir.actions.client"].includes(viewAction.type)) {
|
||||
const options = {};
|
||||
if (this.env.config.breadcrumbs.length > 1) {
|
||||
const breadcrumb = this.env.config.breadcrumbs.slice(-1);
|
||||
await this.action.restore(breadcrumb.jsId);
|
||||
} else {
|
||||
options.clearBreadcrumbs = true;
|
||||
}
|
||||
return this.action.doAction(viewAction, options);
|
||||
}
|
||||
// Note: here we use the pager props, see xml
|
||||
const {limit, offset} = this.props;
|
||||
this.props.onUpdate({offset, limit});
|
||||
if (!limit && !offset) {
|
||||
return;
|
||||
}
|
||||
return this.props.onUpdate({offset, limit});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,7 @@
|
||||
user-select: none;
|
||||
flex-grow: 1;
|
||||
}
|
||||
.o_cp_bottom_right.oe_cp_refresher {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
39
web_refresher/static/src/xml/control_panel.xml
Normal file
39
web_refresher/static/src/xml/control_panel.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- Copyright 2024 Tecnativa - Carlos Roca
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<template>
|
||||
<t
|
||||
t-name="web_refresher.ControlPanel.Regular"
|
||||
t-inherit="web.ControlPanel.Regular"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//div[hasclass('o_cp_bottom_right')]" position="after">
|
||||
<div
|
||||
t-if="!display['bottom-right']"
|
||||
class="o_cp_bottom_right oe_cp_refresher"
|
||||
role="search"
|
||||
t-ref="refresher"
|
||||
>
|
||||
<Refresher />
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
<t
|
||||
t-name="web_refresher.ControlPanel.Small"
|
||||
t-inherit="web.ControlPanel.Small"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//div[hasclass('o_cp_pager')]" position="after">
|
||||
<div
|
||||
t-if="!display['bottom-right']"
|
||||
class="o_cp_bottom_right oe_cp_refresher"
|
||||
role="search"
|
||||
t-ref="refresher"
|
||||
>
|
||||
<Refresher />
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
</template>
|
||||
Reference in New Issue
Block a user