mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_refresher: Addapt changes to OWL
This commit is contained in:
11
web_refresher/static/src/js/control_panel.esm.js
Normal file
11
web_refresher/static/src/js/control_panel.esm.js
Normal 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,
|
||||
});
|
||||
16
web_refresher/static/src/js/refresher.esm.js
Normal file
16
web_refresher/static/src/js/refresher.esm.js
Normal 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";
|
||||
@@ -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;
|
||||
});
|
||||
Reference in New Issue
Block a user