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});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user