diff --git a/web_widget_numeric_step/README.rst b/web_widget_numeric_step/README.rst index d2985fa99..7f71f7a5b 100644 --- a/web_widget_numeric_step/README.rst +++ b/web_widget_numeric_step/README.rst @@ -55,6 +55,14 @@ Example for an 0.25 step, min to -1 and max to 10 : days +**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) + **Examples** Iteration with 0.25 step, min to -1 and max to 10. diff --git a/web_widget_numeric_step/readme/USAGE.rst b/web_widget_numeric_step/readme/USAGE.rst index e272b8022..fabb69723 100644 --- a/web_widget_numeric_step/readme/USAGE.rst +++ b/web_widget_numeric_step/readme/USAGE.rst @@ -15,6 +15,14 @@ Example for an 0.25 step, min to -1 and max to 10 : days +**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) + **Examples** Iteration with 0.25 step, min to -1 and max to 10. diff --git a/web_widget_numeric_step/static/description/index.html b/web_widget_numeric_step/static/description/index.html index 335d0525b..323cd92cd 100644 --- a/web_widget_numeric_step/static/description/index.html +++ b/web_widget_numeric_step/static/description/index.html @@ -398,6 +398,14 @@ Iteration step by default is 1.

 <field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 10}" /> days
 
+

Available Options

+

Examples

Iteration with 0.25 step, min to -1 and max to 10.

Start to increment with button, continue incrementing with scrolling mouse.

diff --git a/web_widget_numeric_step/static/src/js/numeric_step.js b/web_widget_numeric_step/static/src/js/numeric_step.js index b2c5037f9..2d8fd8c2c 100644 --- a/web_widget_numeric_step/static/src/js/numeric_step.js +++ b/web_widget_numeric_step/static/src/js/numeric_step.js @@ -20,7 +20,8 @@ odoo.define("web_widget_numeric_step.field", function(require) { "keydown .input_numeric_step": "_onKeyDown", "change .input_numeric_step": "_onChange", "input .input_numeric_step": "_onInput", - "onfocusout .widget_numeric_step": "_onFocusOut", + "focusin .input_numeric_step": "_onFocusIn", + "focusout .widget_numeric_step": "_onFocusOut", }), supportedFieldTypes: ["float", "integer"], @@ -53,6 +54,7 @@ odoo.define("web_widget_numeric_step.field", function(require) { step: Number(this.nodeOptions.step) || 1, min: Number(min_val), max: Number(max_val), + autoSelect: this.nodeOptions.auto_select, }; this._lazyOnChangeTrigger = _.debounce( @@ -215,6 +217,18 @@ odoo.define("web_widget_numeric_step.field", function(require) { } }, + /** + * Auto select all content when user enters into fields with this + * widget. + * + * @private + */ + _onFocusIn: function() { + if (this._config.autoSelect) { + this.$input.select(); + } + }, + /** * @private * @param {FocusoutEvent} ev