[MIG] web_refresher: Migration to 17.0

pull/2669/head
Taras Shabaranskyi 2023-11-15 12:33:26 +02:00
parent 248cf478c8
commit 21765c4f7e
16 changed files with 289 additions and 76 deletions

View File

@ -17,20 +17,23 @@ Web Refresher
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/16.0/web_refresher :target: https://github.com/OCA/web/tree/17.0/web_refresher
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_refresher :target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_refresher
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
Adds a button next to the pager (in trees/kanban views) to refresh the displayed list. Adds a button next to the pager (in trees/kanban views) to refresh the
displayed list.
.. image:: https://raw.githubusercontent.com/OCA/web/16.0/web_refresher/static/description/refresh.png |image|
.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_refresher/static/description/refresh.png
**Table of contents** **Table of contents**
@ -43,7 +46,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_refresher%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_refresher%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -51,28 +54,30 @@ Credits
======= =======
Authors Authors
~~~~~~~ -------
* Compassion Switzerland * Compassion Switzerland
* Tecnativa * Tecnativa
Contributors Contributors
~~~~~~~~~~~~ ------------
* Samuel Fringeli - Samuel Fringeli
* `Tecnativa <https://www.tecnativa.com>`__: - `Tecnativa <https://www.tecnativa.com>`__:
* João Marques - João Marques
* Alexandre D. Díaz - Alexandre D. Díaz
* Carlos Roca - Carlos Roca
* Thanakrit Pintana - Thanakrit Pintana
* `Factorlibre <https://www.factorlibre.com>`__: - `Factorlibre <https://www.factorlibre.com>`__:
* Hugo Santos - Hugo Santos
- Taras Shabaranskyi
Maintainers Maintainers
~~~~~~~~~~~ -----------
This module is maintained by the OCA. This module is maintained by the OCA.
@ -84,6 +89,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_refresher>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_refresher>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,6 +1,6 @@
{ {
"name": "Web Refresher", "name": "Web Refresher",
"version": "16.0.2.0.0", "version": "17.0.1.0.0",
"author": "Compassion Switzerland, Tecnativa, Odoo Community Association (OCA)", "author": "Compassion Switzerland, Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
@ -11,9 +11,9 @@
"web.assets_backend": [ "web.assets_backend": [
"web_refresher/static/src/scss/refresher.scss", "web_refresher/static/src/scss/refresher.scss",
"web_refresher/static/src/js/refresher.esm.js", "web_refresher/static/src/js/refresher.esm.js",
"web_refresher/static/src/js/pager.esm.js", "web_refresher/static/src/js/control_panel.esm.js",
"web_refresher/static/src/xml/refresher.xml", "web_refresher/static/src/xml/refresher.xml",
"web_refresher/static/src/xml/pager.xml", "web_refresher/static/src/xml/control_panel.xml",
], ],
}, },
} }

View File

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_refresher
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-12-09 14:45+0000\n"
"Last-Translator: Nils Coenen | NICO SOLUTIONS - ENGINEERING & IT <nils."
"coenen@nico-solutions.de>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"
#. module: web_refresher
#. openerp-web
#: code:addons/web_refresher/static/src/xml/refresher.xml:0
#, python-format
msgid "Pager"
msgstr ""
#. module: web_refresher
#. openerp-web
#: code:addons/web_refresher/static/src/xml/refresher.xml:0
#, python-format
msgid "Refresh"
msgstr "Aktualisieren"

View File

@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_refresher
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0-20231113\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-15 08:17+0000\n"
"PO-Revision-Date: 2023-11-15 08:17+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_refresher
#. odoo-javascript
#: code:addons/web_refresher/static/src/xml/refresher.xml:0
#: code:addons/web_refresher/static/src/xml/refresher.xml:0
#, python-format
msgid "Refresh"
msgstr "Оновити"
#. module: web_refresher
#. odoo-javascript
#: code:addons/web_refresher/static/src/js/refresher.esm.js:0
#, python-format
msgid "Refreshed"
msgstr "Оновлено"
#. module: web_refresher
#. odoo-javascript
#: code:addons/web_refresher/static/src/xml/refresher.xml:0
#, python-format
msgid "Refresher"
msgstr "Оновлювач"

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,9 @@
- Samuel Fringeli
- [Tecnativa](https://www.tecnativa.com):
- João Marques
- Alexandre D. Díaz
- Carlos Roca
- Thanakrit Pintana
- [Factorlibre](https://www.factorlibre.com):
- Hugo Santos
- Taras Shabaranskyi

View File

@ -1,11 +0,0 @@
* Samuel Fringeli
* `Tecnativa <https://www.tecnativa.com>`__:
* João Marques
* Alexandre D. Díaz
* Carlos Roca
* Thanakrit Pintana
* `Factorlibre <https://www.factorlibre.com>`__:
* Hugo Santos

View File

@ -0,0 +1,4 @@
Adds a button next to the pager (in trees/kanban views) to refresh the
displayed list.
![image](./static/description/refresh.png)

View File

@ -1,3 +0,0 @@
Adds a button next to the pager (in trees/kanban views) to refresh the displayed list.
.. image:: ./static/description/refresh.png

View File

@ -369,9 +369,10 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e460bec11bb6df47946d267a2e46008defe2172b626f0f7c2474478d9e9096df !! source digest: sha256:e460bec11bb6df47946d267a2e46008defe2172b626f0f7c2474478d9e9096df
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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><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/17.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-17-0/web-17-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=17.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> <p>Adds a button next to the pager (in trees/kanban views) to refresh the
<img alt="https://raw.githubusercontent.com/OCA/web/16.0/web_refresher/static/description/refresh.png" src="https://raw.githubusercontent.com/OCA/web/16.0/web_refresher/static/description/refresh.png" /> displayed list.</p>
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/web/17.0/web_refresher/static/description/refresh.png" /></p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
@ -389,7 +390,7 @@ ul.auto-toc {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_refresher%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_refresher%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -416,6 +417,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Hugo Santos</li> <li>Hugo Santos</li>
</ul> </ul>
</li> </li>
<li>Taras Shabaranskyi</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -425,7 +427,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_refresher">OCA/web</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_refresher">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -0,0 +1,30 @@
/** @odoo-module **/
/* Copyright 2022 Tecnativa - Alexandre D. Díaz
* Copyright 2022 Tecnativa - Carlos Roca
* Copyright 2023 Taras Shabaranskyi
* 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";
import {patch} from "@web/core/utils/patch";
patch(ControlPanel, {
components: {...ControlPanel.components, Refresher},
});
patch(ControlPanel.prototype, {
/**
* @returns {{searchModel: Object<*>, pagerProps: Object<*>}|null}
*/
get refresherProps() {
const {config, searchModel} = this.env;
const forbiddenSubType = ["base_settings"];
if (forbiddenSubType.includes(config.viewSubType)) {
return null;
}
return {
searchModel: searchModel,
pagerProps: this.pagerProps,
};
},
});

View File

@ -1,9 +0,0 @@
/** @odoo-module **/
/* Copyright 2022 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {Pager} from "@web/core/pager/pager";
import {Refresher} from "./refresher.esm";
Pager.components = Object.assign({}, Pager.components, {
Refresher,
});

View File

@ -1,16 +1,109 @@
/** @odoo-module **/ /** @odoo-module **/
/* Copyright 2022 Tecnativa - Alexandre D. Díaz /* Copyright 2022 Tecnativa - Alexandre D. Díaz
* Copyright 2022 Tecnativa - Carlos Roca * Copyright 2022 Tecnativa - Carlos Roca
* Copyright 2023 Taras Shabaranskyi
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
const {Component} = owl; import {Component} from "@odoo/owl";
import {useDebounced} from "@web/core/utils/timing";
export function useRefreshAnimation(timeout) {
const refreshClass = "o_content__refresh";
let timeoutId = null;
/**
* @returns {DOMTokenList|null}
*/
function contentClassList() {
const content = document.querySelector(".o_content");
return content ? content.classList : null;
}
function clearAnimationTimeout() {
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = null;
}
function animate() {
clearAnimationTimeout();
contentClassList().add(refreshClass);
timeoutId = setTimeout(() => {
contentClassList().remove(refreshClass);
clearAnimationTimeout();
}, timeout);
}
return animate;
}
export class Refresher extends Component { export class Refresher extends Component {
_doRefresh() { setup() {
// Note: here we use the pager props, see xml super.setup();
const {limit, offset} = this.props; this.refreshAnimation = useRefreshAnimation(1000);
this.props.onUpdate({offset, limit}); this.onClickRefresh = useDebounced(this.onClickRefresh, 200);
}
/**
* @returns {Boolean}
*/
get displayButton() {
const {searchModel, pagerProps} = this.props;
const hasSearchModel = searchModel && searchModel.search;
return Boolean(hasSearchModel || (pagerProps && pagerProps.onUpdate));
}
/**
* @returns {Boolean}
* @private
*/
_searchModelRefresh() {
const {searchModel} = this.props;
if (searchModel && typeof searchModel.search === "function") {
searchModel.search();
return true;
}
return false;
}
/**
* @returns {Promise<Boolean>}
* @private
*/
async _pagerRefresh() {
const pagerProps = this.props.pagerProps;
if (pagerProps && typeof pagerProps.onUpdate === "function") {
const {limit, offset} = pagerProps;
await pagerProps.onUpdate({offset, limit});
return true;
}
return false;
}
/**
* @returns {Promise<Boolean>}
*/
async refresh() {
let updated = this._searchModelRefresh();
if (!updated) {
updated = await this._pagerRefresh();
}
return updated;
}
async onClickRefresh() {
const updated = await this.refresh();
if (updated) {
this.refreshAnimation();
}
} }
} }
Refresher.template = "web_refresher.Button"; Object.assign(Refresher, {
template: "web_refresher.Button",
props: {
searchModel: {type: Object, optional: true},
pagerProps: {type: Object, optional: true},
},
});

View File

@ -1,7 +1,23 @@
.oe_cp_refresher { .oe_cp_refresher {
margin: auto 0 auto auto; margin: auto 0 auto 0;
padding-left: 5px;
text-align: right;
user-select: none; user-select: none;
flex-grow: 1; }
.o_content {
&__refresh {
animation: web_refresh 0.6s ease;
}
}
@keyframes web_refresh {
0% {
opacity: 1;
}
50% {
transform: translateY(10px);
opacity: 0.6;
}
100% {
opacity: 1;
}
} }

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2022 Tecnativa - Carlos Roca <!-- Copyright 2022 Tecnativa - Alexandre Díaz
Copyright 2023 Taras Shabaranskyi
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<template> <template>
<t <t
t-name="web_refresher.Pager" t-name="web_refresher.ControlPanel"
t-inherit="web.Pager" t-inherit="web.ControlPanel"
t-inherit-mode="extension" t-inherit-mode="extension"
owl="1"
> >
<xpath expr="//span[hasclass('o_pager_counter')]" position="before"> <xpath expr="//div[hasclass('o_cp_pager')]" position="before">
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher t-props="props" /> <Refresher t-props="refresherProps" />
</div> </div>
</xpath> </xpath>
</t> </t>

View File

@ -1,18 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2022 Tecnativa - Alexandre Díaz <!-- Copyright 2022 Tecnativa - Alexandre Díaz
Copyright 2023 Taras Shabaranskyi
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<template> <template>
<t t-name="web_refresher.Button" owl="1"> <t t-name="web_refresher.Button">
<nav class="oe_refresher" aria-label="Pager"> <nav
<span aria-atomic="true"> class="oe_refresher"
<button aria-label="Refresher"
class="fa fa-refresh btn btn-icon oe_pager_refresh" aria-atomic="true"
aria-label="Refresh" t-if="displayButton"
t-on-click="_doRefresh" >
title="Refresh" <button
tabindex="-1" class="fa fa-refresh btn btn-icon oe_pager_refresh"
/> aria-label="Refresh"
</span> t-on-click="onClickRefresh"
title="Refresh"
tabindex="-1"
/>
</nav> </nav>
</t> </t>
</template> </template>