mirror of https://github.com/OCA/web.git
[IMP] web_widget_numeric_step: Add auto_select option
parent
69a3d5f683
commit
7c266307d0
|
@ -55,6 +55,14 @@ Example for an 0.25 step, min to -1 and max to 10 :
|
||||||
|
|
||||||
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 10}" /> days
|
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 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**
|
**Examples**
|
||||||
|
|
||||||
Iteration with 0.25 step, min to -1 and max to 10.
|
Iteration with 0.25 step, min to -1 and max to 10.
|
||||||
|
|
|
@ -15,6 +15,14 @@ Example for an 0.25 step, min to -1 and max to 10 :
|
||||||
|
|
||||||
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 10}" /> days
|
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 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**
|
**Examples**
|
||||||
|
|
||||||
Iteration with 0.25 step, min to -1 and max to 10.
|
Iteration with 0.25 step, min to -1 and max to 10.
|
||||||
|
|
|
@ -398,6 +398,14 @@ Iteration step by default is 1.</p>
|
||||||
<pre class="code xml literal-block">
|
<pre class="code xml literal-block">
|
||||||
<span class="nt"><field</span> <span class="na">name=</span><span class="s">"sale_delay"</span> <span class="na">widget=</span><span class="s">"numeric_step"</span> <span class="na">options=</span><span class="s">"{'step': 0.25, 'min': -1, 'max': 10}"</span> <span class="nt">/></span> days
|
<span class="nt"><field</span> <span class="na">name=</span><span class="s">"sale_delay"</span> <span class="na">widget=</span><span class="s">"numeric_step"</span> <span class="na">options=</span><span class="s">"{'step': 0.25, 'min': -1, 'max': 10}"</span> <span class="nt">/></span> days
|
||||||
</pre>
|
</pre>
|
||||||
|
<p><strong>Available Options</strong></p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>step > Amount to increase/decrease (default: 1.0)</li>
|
||||||
|
<li>min > Min. value allowed (default: no limit)</li>
|
||||||
|
<li>max > Max. value allowed (default: no limit)</li>
|
||||||
|
<li>auto_select > Select the content when the element get focus (default: False)</li>
|
||||||
|
<li>placeholder > Define the placeholder text (default: None)</li>
|
||||||
|
</ul>
|
||||||
<p><strong>Examples</strong></p>
|
<p><strong>Examples</strong></p>
|
||||||
<p>Iteration with 0.25 step, min to -1 and max to 10.</p>
|
<p>Iteration with 0.25 step, min to -1 and max to 10.</p>
|
||||||
<p>Start to increment with button, continue incrementing with scrolling mouse.</p>
|
<p>Start to increment with button, continue incrementing with scrolling mouse.</p>
|
||||||
|
|
|
@ -20,7 +20,8 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
"keydown .input_numeric_step": "_onKeyDown",
|
"keydown .input_numeric_step": "_onKeyDown",
|
||||||
"change .input_numeric_step": "_onChange",
|
"change .input_numeric_step": "_onChange",
|
||||||
"input .input_numeric_step": "_onInput",
|
"input .input_numeric_step": "_onInput",
|
||||||
"onfocusout .widget_numeric_step": "_onFocusOut",
|
"focusin .input_numeric_step": "_onFocusIn",
|
||||||
|
"focusout .widget_numeric_step": "_onFocusOut",
|
||||||
}),
|
}),
|
||||||
supportedFieldTypes: ["float", "integer"],
|
supportedFieldTypes: ["float", "integer"],
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
step: Number(this.nodeOptions.step) || 1,
|
step: Number(this.nodeOptions.step) || 1,
|
||||||
min: Number(min_val),
|
min: Number(min_val),
|
||||||
max: Number(max_val),
|
max: Number(max_val),
|
||||||
|
autoSelect: this.nodeOptions.auto_select,
|
||||||
};
|
};
|
||||||
|
|
||||||
this._lazyOnChangeTrigger = _.debounce(
|
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
|
* @private
|
||||||
* @param {FocusoutEvent} ev
|
* @param {FocusoutEvent} ev
|
||||||
|
|
Loading…
Reference in New Issue