[IMP] web_refresher: Addapt changes to OWL

This commit is contained in:
Carlos Roca
2022-12-20 10:25:26 +01:00
parent 1313ba87fc
commit 5f1b8643d0
9 changed files with 58 additions and 76 deletions

View File

@@ -0,0 +1,11 @@
/** @odoo-module **/
/* Copyright 2022 Tecnativa - Alexandre D. Díaz
* Copyright 2022 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import LegacyControlPanel from "web.ControlPanel";
import {Refresher} from "./refresher.esm";
// Patch control panel to initialize refresher component
LegacyControlPanel.components = Object.assign({}, LegacyControlPanel.components, {
Refresher,
});

View File

@@ -0,0 +1,16 @@
/** @odoo-module **/
/* Copyright 2022 Tecnativa - Alexandre D. Díaz
* Copyright 2022 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
const {Component} = owl;
export class Refresher extends Component {
_doRefresh() {
// Note: here we use the pager props, see xml
const {limit, currentMinimum} = this.props;
this.trigger("pager-changed", {currentMinimum, limit});
}
}
Refresher.template = "web_refresher.Button";

View File

@@ -1,42 +0,0 @@
/* Copyright 2022 Tecnativa - Alexandre D. Díaz
* License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("refresher.Refresher", function (require) {
"use strict";
const ControlPanel = require("web.ControlPanel");
const {Component, hooks} = owl;
const {useRef} = hooks;
class Refresher extends Component {
_doRefresh() {
// Note: here we use the pager props, see xml
const {limit, currentMinimum} = this.props;
this.trigger("pager-changed", {currentMinimum, limit});
}
}
Refresher.template = "web_refresher.Button";
// Patch control panel to initialize refresher component
ControlPanel.components = Object.assign({}, ControlPanel.components, {
Refresher,
});
ControlPanel.patch("web_refresher.ControlPanel", (T) => {
class ControlPanelRefresher extends T {
constructor() {
super(...arguments);
if ("cp_content" in this.props) {
const content = this.props.cp_content || {};
if ("$refresher" in content) {
this.additionalContent.refresher = content.$refresher;
}
}
this.contentRefs.refresher = useRef("refresher");
}
}
return ControlPanelRefresher;
});
return Refresher;
});