From da87e9e3313a4364a392a6b741d58d134189b27c Mon Sep 17 00:00:00 2001
From: David <david.vidal@tecnativa.com>
Date: Fri, 12 Jul 2024 13:22:29 +0200
Subject: [PATCH] [IMP] web_widget_numeric_step: be able to add classes

If we set a class in the field it will get to the widget template.

TT54358
---
 web_widget_numeric_step/README.rst            | 29 ++++++++++---------
 web_widget_numeric_step/readme/USAGE.md       |  1 +
 .../static/description/index.html             |  1 +
 .../static/src/numeric_step.esm.js            |  2 ++
 .../static/src/numeric_step.xml               |  4 +--
 5 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/web_widget_numeric_step/README.rst b/web_widget_numeric_step/README.rst
index 109481f07..3cb1c56ae 100644
--- a/web_widget_numeric_step/README.rst
+++ b/web_widget_numeric_step/README.rst
@@ -63,12 +63,13 @@ Example for an 0.25 step, min to -1 and max to 10 :
 
 **Available Options**
 
-- step > Amount to increase/decrease (default: 1.0)
-- min > Min. value allowed (default: no limit)
-- max > Max. value allowed (default: no limit)
-- auto_select > Select the content when the element get focus (default:
-  False)
-- placeholder > Define the placeholder text (default: None)
+-  step > Amount to increase/decrease (default: 1.0)
+-  min > Min. value allowed (default: no limit)
+-  max > Max. value allowed (default: no limit)
+-  auto_select > Select the content when the element get focus (default:
+   False)
+-  placeholder > Define the placeholder text (default: None)
+-  class > Define additional classes for the input (default: None)
 
 **Examples**
 
@@ -121,18 +122,18 @@ Authors
 Contributors
 ------------
 
-- `GRAP <http://www.grap.coop>`__:
+-  `GRAP <http://www.grap.coop>`__:
 
-  - Quentin DUPONT <quentin.dupont@grap.coop>
+   -  Quentin DUPONT <quentin.dupont@grap.coop>
 
-- `Tecnativa <https://www.tecnativa.com/>`__:
+-  `Tecnativa <https://www.tecnativa.com/>`__:
 
-  - Alexandre Díaz
-  - Carlos Roca
+   -  Alexandre Díaz
+   -  Carlos Roca
 
-- Helly kapatel <helly.kapatel@initos.com>
-- Thanakrit Pintana <thanakrit.p39@gmail.com>
-- Dhara Solanki <dhara.solanki@initos.com>
+-  Helly kapatel <helly.kapatel@initos.com>
+-  Thanakrit Pintana <thanakrit.p39@gmail.com>
+-  Dhara Solanki <dhara.solanki@initos.com>
 
 Maintainers
 -----------
diff --git a/web_widget_numeric_step/readme/USAGE.md b/web_widget_numeric_step/readme/USAGE.md
index e95f2e4dc..5d5e2d88b 100644
--- a/web_widget_numeric_step/readme/USAGE.md
+++ b/web_widget_numeric_step/readme/USAGE.md
@@ -23,6 +23,7 @@ Example for an 0.25 step, min to -1 and max to 10 :
 - auto_select \> Select the content when the element get focus (default:
   False)
 - placeholder \> Define the placeholder text (default: None)
+- class \> Define additional classes for the input (default: None)
 
 **Examples**
 
diff --git a/web_widget_numeric_step/static/description/index.html b/web_widget_numeric_step/static/description/index.html
index 8c4844864..3f42d54ce 100644
--- a/web_widget_numeric_step/static/description/index.html
+++ b/web_widget_numeric_step/static/description/index.html
@@ -411,6 +411,7 @@ values).</p>
 <li>auto_select &gt; Select the content when the element get focus (default:
 False)</li>
 <li>placeholder &gt; Define the placeholder text (default: None)</li>
+<li>class &gt; Define additional classes for the input (default: None)</li>
 </ul>
 <p><strong>Examples</strong></p>
 <p>Iteration with 0.25 step, min to -1 and max to 10.</p>
diff --git a/web_widget_numeric_step/static/src/numeric_step.esm.js b/web_widget_numeric_step/static/src/numeric_step.esm.js
index 25c76db7a..002591b87 100644
--- a/web_widget_numeric_step/static/src/numeric_step.esm.js
+++ b/web_widget_numeric_step/static/src/numeric_step.esm.js
@@ -62,6 +62,7 @@ NumericStep.props = {
     min: {type: Number, optional: true},
     max: {type: Number, optional: true},
     placeholder: {type: String, optional: true},
+    additional_class: {type: String, optional: true},
 };
 NumericStep.defaultProps = {
     ...FloatField.defaultProps,
@@ -80,6 +81,7 @@ export const numericStep = {
             min: options.min,
             max: options.max,
             placeholder: attrs.placeholder,
+            additional_class: attrs.class,
         };
     },
 };
diff --git a/web_widget_numeric_step/static/src/numeric_step.xml b/web_widget_numeric_step/static/src/numeric_step.xml
index 51c4b05ad..f6aa28637 100644
--- a/web_widget_numeric_step/static/src/numeric_step.xml
+++ b/web_widget_numeric_step/static/src/numeric_step.xml
@@ -6,7 +6,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 -->
 <template>
     <t t-name="web_widget_numeric_step">
-        <div class="d-flex widget_numeric_step">
+        <div t-attf-class="d-flex widget_numeric_step {{props.additional_class or ''}}">
             <div class="input-group-prepend widget_numeric_step_btn">
                 <button
                     class="fa fa-minus btn btn-default btn_numeric_step"
@@ -24,7 +24,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
                 t-ref="numpadDecimal"
                 t-att-placeholder="props.placeholder"
                 t-att-type="props.inputType"
-                class="o_input input_numeric_step"
+                class="o_input"
                 inputmode="decimal"
                 t-att-step="props.step"
                 t-on-keydown="_onKeyDown"