Skip to content

Commit

Permalink
[IMP] web_refresher: Provide the ability to reload information from a…
Browse files Browse the repository at this point in the history
… report view
  • Loading branch information
CarlosRoca13 committed Feb 9, 2024
1 parent 10a600b commit c044cab
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web_refresher/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Web Refresher
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e460bec11bb6df47946d267a2e46008defe2172b626f0f7c2474478d9e9096df
!! source digest: sha256:c5a87e1531dfe91e360d9f92c4b110bda762f4e85405a12ae847e6fbcfc55815
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 2 additions & 0 deletions web_refresher/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"web.assets_backend": [
"web_refresher/static/src/scss/refresher.scss",
"web_refresher/static/src/js/refresher.esm.js",
"web_refresher/static/src/js/control_panel.esm.js",
"web_refresher/static/src/js/pager.esm.js",
"web_refresher/static/src/xml/refresher.xml",
"web_refresher/static/src/xml/control_panel.xml",
"web_refresher/static/src/xml/pager.xml",
],
},
Expand Down
2 changes: 1 addition & 1 deletion web_refresher/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Web Refresher</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e460bec11bb6df47946d267a2e46008defe2172b626f0f7c2474478d9e9096df
!! source digest: sha256:c5a87e1531dfe91e360d9f92c4b110bda762f4e85405a12ae847e6fbcfc55815
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_refresher"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_refresher"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a button next to the pager (in trees/kanban views) to refresh the displayed list.</p>
Expand Down
9 changes: 9 additions & 0 deletions web_refresher/static/src/js/control_panel.esm.js
Original file line number Diff line number Diff line change
@@ -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,
});
24 changes: 22 additions & 2 deletions web_refresher/static/src/js/refresher.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
}

Expand Down
4 changes: 4 additions & 0 deletions web_refresher/static/src/scss/refresher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
user-select: none;
flex-grow: 1;
}
.o_cp_bottom_right.oe_cp_refresher {
display: flex;
flex-direction: row-reverse;
}
39 changes: 39 additions & 0 deletions web_refresher/static/src/xml/control_panel.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit c044cab

Please sign in to comment.