From b6ca76d338a976bc59987fcb874376faed172317 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 14 Dec 2023 12:45:45 +0000 Subject: [PATCH] [FIX] web_widget_numeric_step: always display on touch screens; avoid layout jumping otherwise Before this patch: - On a tablet, buttons wouldn't display (big screen; can't hover). - On a PC, fields would make layout jumps while hovering. @moduon MT-4472 --- web_widget_numeric_step/README.rst | 13 ++++++++++++- web_widget_numeric_step/__manifest__.py | 4 ++-- .../static/description/index.html | 5 ++++- .../static/src/{js => }/numeric_step.esm.js | 9 --------- .../static/src/numeric_step.scss | 14 ++++++++++++++ .../static/src/{xml => }/numeric_step.xml | 10 +++------- 6 files changed, 35 insertions(+), 20 deletions(-) rename web_widget_numeric_step/static/src/{js => }/numeric_step.esm.js (88%) create mode 100644 web_widget_numeric_step/static/src/numeric_step.scss rename web_widget_numeric_step/static/src/{xml => }/numeric_step.xml (82%) diff --git a/web_widget_numeric_step/README.rst b/web_widget_numeric_step/README.rst index 14be29306..085b3eb82 100644 --- a/web_widget_numeric_step/README.rst +++ b/web_widget_numeric_step/README.rst @@ -7,7 +7,7 @@ Web Widget Numeric Step !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:672d53d5bf482d0938c82f0a39d665f9f5d133fe3dd5401bcb9488ac95797c12 + !! source digest: sha256:a92ee94458249bb7f5306ec54ef8f048f2fe887791c948e533c958d1cffe87f3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -126,6 +126,17 @@ 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. +.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px + :target: https://github.com/rafaelbn + :alt: rafaelbn +.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px + :target: https://github.com/yajo + :alt: yajo + +Current `maintainers `__: + +|maintainer-rafaelbn| |maintainer-yajo| + 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_widget_numeric_step/__manifest__.py b/web_widget_numeric_step/__manifest__.py index 4634da56a..112680fb7 100644 --- a/web_widget_numeric_step/__manifest__.py +++ b/web_widget_numeric_step/__manifest__.py @@ -12,10 +12,10 @@ "depends": ["web"], "assets": { "web.assets_backend": [ - "web_widget_numeric_step/static/src/xml/numeric_step.xml", - "web_widget_numeric_step/static/src/js/numeric_step.esm.js", + "web_widget_numeric_step/static/src/*", ], }, + "maintainers": ["rafaelbn", "yajo"], "auto_install": False, "installable": True, } diff --git a/web_widget_numeric_step/static/description/index.html b/web_widget_numeric_step/static/description/index.html index c723fcee4..e8505a3c5 100644 --- a/web_widget_numeric_step/static/description/index.html +++ b/web_widget_numeric_step/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:672d53d5bf482d0938c82f0a39d665f9f5d133fe3dd5401bcb9488ac95797c12 +!! source digest: sha256:a92ee94458249bb7f5306ec54ef8f048f2fe887791c948e533c958d1cffe87f3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This widget changes input number field and make it easier to increment the number thanks to 2 buttons (+ and -). @@ -459,6 +460,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

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.

+

Current maintainers:

+

rafaelbn yajo

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_widget_numeric_step/static/src/js/numeric_step.esm.js b/web_widget_numeric_step/static/src/numeric_step.esm.js similarity index 88% rename from web_widget_numeric_step/static/src/js/numeric_step.esm.js rename to web_widget_numeric_step/static/src/numeric_step.esm.js index aebc06f27..6defd19ec 100644 --- a/web_widget_numeric_step/static/src/js/numeric_step.esm.js +++ b/web_widget_numeric_step/static/src/numeric_step.esm.js @@ -9,14 +9,6 @@ export class NumericStep extends FloatField { setup() { super.setup(); } - _onFocusInput(ev) { - const $el = $(ev.target).parent().find(".widget_numeric_step_btn"); - $el.removeClass("d-lg-none"); - } - _onFocusOutInput(ev) { - const $el = $(ev.target).find(".widget_numeric_step_btn"); - $el.addClass("d-lg-none"); - } _onStepClick(ev) { const $el = $(ev.target).parent().parent().find("input"); $el.focus(); @@ -65,7 +57,6 @@ export class NumericStep extends FloatField { NumericStep.template = "web_widget_numeric_step"; NumericStep.props = { ...standardFieldProps, - name: {type: String, optional: true}, inputType: {type: String, optional: true}, step: {type: Number, optional: true}, min: {type: Number, optional: true}, diff --git a/web_widget_numeric_step/static/src/numeric_step.scss b/web_widget_numeric_step/static/src/numeric_step.scss new file mode 100644 index 000000000..b7ed1c492 --- /dev/null +++ b/web_widget_numeric_step/static/src/numeric_step.scss @@ -0,0 +1,14 @@ +// Copyright 2023 Moduon Team S.L. +// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +.widget_numeric_step { + // Hide the buttons until the user hovers if possible + @media (hover: hover) { + .btn_numeric_step { + visibility: hidden; + } + } + &:hover .btn_numeric_step { + visibility: visible; + } +} diff --git a/web_widget_numeric_step/static/src/xml/numeric_step.xml b/web_widget_numeric_step/static/src/numeric_step.xml similarity index 82% rename from web_widget_numeric_step/static/src/xml/numeric_step.xml rename to web_widget_numeric_step/static/src/numeric_step.xml index be8ebde7c..1b7e2b57e 100644 --- a/web_widget_numeric_step/static/src/xml/numeric_step.xml +++ b/web_widget_numeric_step/static/src/numeric_step.xml @@ -6,12 +6,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->