diff --git a/web_refresher/README.rst b/web_refresher/README.rst new file mode 100644 index 000000000..7f71a9747 --- /dev/null +++ b/web_refresher/README.rst @@ -0,0 +1,94 @@ +============= +Web Refresher +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e460bec11bb6df47946d267a2e46008defe2172b626f0f7c2474478d9e9096df + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/17.0/web_refresher + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_refresher + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds a button next to the pager (in trees/kanban views) to refresh the +displayed list. + +|image| + +.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_refresher/static/description/refresh.png + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Compassion Switzerland +* Tecnativa + +Contributors +------------ + +- Samuel Fringeli +- `Tecnativa `__: + + - João Marques + - Alexandre D. Díaz + - Carlos Roca + +- Thanakrit Pintana +- `Factorlibre `__: + + - Hugo Santos + +- Taras Shabaranskyi + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_refresher/__init__.py b/web_refresher/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_refresher/__manifest__.py b/web_refresher/__manifest__.py new file mode 100644 index 000000000..14f24f30b --- /dev/null +++ b/web_refresher/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Web Refresher", + "version": "17.0.1.0.0", + "author": "Compassion Switzerland, Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/web", + "depends": ["web"], + "installable": True, + "auto_install": False, + "assets": { + "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/xml/refresher.xml", + "web_refresher/static/src/xml/control_panel.xml", + ], + }, +} diff --git a/web_refresher/i18n/ca.po b/web_refresher/i18n/ca.po new file mode 100644 index 000000000..e5b065d50 --- /dev/null +++ b/web_refresher/i18n/ca.po @@ -0,0 +1,13 @@ +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Pager" +msgstr "" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Refresh" +msgstr "" diff --git a/web_refresher/i18n/de.po b/web_refresher/i18n/de.po new file mode 100644 index 000000000..39740b816 --- /dev/null +++ b/web_refresher/i18n/de.po @@ -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 \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" diff --git a/web_refresher/i18n/es.po b/web_refresher/i18n/es.po new file mode 100644 index 000000000..36cfe291f --- /dev/null +++ b/web_refresher/i18n/es.po @@ -0,0 +1,29 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-02 20:35+0000\n" +"PO-Revision-Date: 2023-09-02 20:35+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: LANGUAGE \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: ENCODING\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Pager" +msgstr "Buscapersonas" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Refresh" +msgstr "Actualizar" diff --git a/web_refresher/i18n/fr.po b/web_refresher/i18n/fr.po new file mode 100644 index 000000000..5f0aa6ead --- /dev/null +++ b/web_refresher/i18n/fr.po @@ -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 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-06 17:37+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: none\n" +"Language: fr\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.17\n" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Pager" +msgstr "" + +#. 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 "Actualiser" diff --git a/web_refresher/i18n/hr.po b/web_refresher/i18n/hr.po new file mode 100644 index 000000000..2afa96601 --- /dev/null +++ b/web_refresher/i18n/hr.po @@ -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 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-01-04 02:42+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Pager" +msgstr "Stranice" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Refresh" +msgstr "Osvježi" diff --git a/web_refresher/i18n/pt_BR.po b/web_refresher/i18n/pt_BR.po new file mode 100644 index 000000000..e5b065d50 --- /dev/null +++ b/web_refresher/i18n/pt_BR.po @@ -0,0 +1,13 @@ +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Pager" +msgstr "" + +#. module: web_refresher +#. odoo-javascript +#: code:addons/web_refresher/static/src/xml/refresher.xml:0 +#, python-format +msgid "Refresh" +msgstr "" diff --git a/web_refresher/i18n/uk_UA.po b/web_refresher/i18n/uk_UA.po new file mode 100644 index 000000000..4bfdd3734 --- /dev/null +++ b/web_refresher/i18n/uk_UA.po @@ -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 "Оновлювач" diff --git a/web_refresher/i18n/web_refresher.pot b/web_refresher/i18n/web_refresher.pot new file mode 100644 index 000000000..4ebec229e --- /dev/null +++ b/web_refresher/i18n/web_refresher.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_refresher +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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 +#, python-format +msgid "Pager" +msgstr "" + +#. 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 "" diff --git a/web_refresher/pyproject.toml b/web_refresher/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/web_refresher/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_refresher/readme/CONTRIBUTORS.md b/web_refresher/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..c95363164 --- /dev/null +++ b/web_refresher/readme/CONTRIBUTORS.md @@ -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 diff --git a/web_refresher/readme/DESCRIPTION.md b/web_refresher/readme/DESCRIPTION.md new file mode 100644 index 000000000..5def2b53b --- /dev/null +++ b/web_refresher/readme/DESCRIPTION.md @@ -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) diff --git a/web_refresher/static/description/icon.png b/web_refresher/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_refresher/static/description/icon.png differ diff --git a/web_refresher/static/description/index.html b/web_refresher/static/description/index.html new file mode 100644 index 000000000..6164474f8 --- /dev/null +++ b/web_refresher/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Web Refresher + + + +
+

Web Refresher

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Adds a button next to the pager (in trees/kanban views) to refresh the +displayed list.

+

image

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Compassion Switzerland
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Samuel Fringeli
  • +
  • Tecnativa:
      +
    • João Marques
    • +
    • Alexandre D. Díaz
    • +
    • Carlos Roca
    • +
    +
  • +
  • Thanakrit Pintana
  • +
  • Factorlibre:
      +
    • Hugo Santos
    • +
    +
  • +
  • Taras Shabaranskyi
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_refresher/static/description/refresh.png b/web_refresher/static/description/refresh.png new file mode 100644 index 000000000..900f4a989 Binary files /dev/null and b/web_refresher/static/description/refresh.png differ diff --git a/web_refresher/static/src/js/control_panel.esm.js b/web_refresher/static/src/js/control_panel.esm.js new file mode 100644 index 000000000..b11aa7b86 --- /dev/null +++ b/web_refresher/static/src/js/control_panel.esm.js @@ -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, + }; + }, +}); diff --git a/web_refresher/static/src/js/refresher.esm.js b/web_refresher/static/src/js/refresher.esm.js new file mode 100644 index 000000000..60c570ad9 --- /dev/null +++ b/web_refresher/static/src/js/refresher.esm.js @@ -0,0 +1,109 @@ +/** @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 {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 { + setup() { + super.setup(); + this.refreshAnimation = useRefreshAnimation(1000); + 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} + * @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} + */ + 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(); + } + } +} + +Object.assign(Refresher, { + template: "web_refresher.Button", + props: { + searchModel: {type: Object, optional: true}, + pagerProps: {type: Object, optional: true}, + }, +}); diff --git a/web_refresher/static/src/scss/refresher.scss b/web_refresher/static/src/scss/refresher.scss new file mode 100644 index 000000000..ef59aa819 --- /dev/null +++ b/web_refresher/static/src/scss/refresher.scss @@ -0,0 +1,23 @@ +.oe_cp_refresher { + margin: auto 0 auto 0; + user-select: none; +} + +.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; + } +} diff --git a/web_refresher/static/src/xml/control_panel.xml b/web_refresher/static/src/xml/control_panel.xml new file mode 100644 index 000000000..0f0e8b2f5 --- /dev/null +++ b/web_refresher/static/src/xml/control_panel.xml @@ -0,0 +1,17 @@ + + + diff --git a/web_refresher/static/src/xml/refresher.xml b/web_refresher/static/src/xml/refresher.xml new file mode 100644 index 000000000..59954a478 --- /dev/null +++ b/web_refresher/static/src/xml/refresher.xml @@ -0,0 +1,22 @@ + + +