mirror of https://github.com/OCA/web.git
[MIG] web_widget_numeric_step: Migration to v13
parent
01fbf68de8
commit
45ceadcf0a
|
@ -14,13 +14,13 @@ Web Widget Numeric Step
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/web/tree/12.0/web_widget_numeric_step
|
:target: https://github.com/OCA/web/tree/13.0/web_widget_numeric_step
|
||||||
:alt: OCA/web
|
:alt: OCA/web
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_numeric_step
|
:target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_numeric_step
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/162/12.0
|
:target: https://runbot.odoo-community.org/runbot/162/13.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
@ -42,7 +42,7 @@ In your xml view, add ``widget="numeric_step"``
|
||||||
This will add the 2 buttons "+" and "-" just next to the input field in edit mode.
|
This will add the 2 buttons "+" and "-" just next to the input field in edit mode.
|
||||||
Iteration step by default is 1.
|
Iteration step by default is 1.
|
||||||
|
|
||||||
.. figure:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/add_two_buttons.png
|
.. figure:: https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/add_two_buttons.png
|
||||||
|
|
||||||
|
|
||||||
**Optional**
|
**Optional**
|
||||||
|
@ -61,11 +61,11 @@ Iteration with 0.25 step, min to -1 and max to 10.
|
||||||
|
|
||||||
Start to increment with button, continue incrementing with scrolling mouse.
|
Start to increment with button, continue incrementing with scrolling mouse.
|
||||||
|
|
||||||
.. figure:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step0,25andlimits.gif
|
.. figure:: https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step0,25andlimits.gif
|
||||||
|
|
||||||
Iteration with 10 step, max limit 15, placeholder with onchange
|
Iteration with 10 step, max limit 15, placeholder with onchange
|
||||||
|
|
||||||
.. figure:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif
|
.. figure:: https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
@ -73,7 +73,7 @@ Bug Tracker
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ Contributors
|
||||||
* `Tecnativa <https://www.tecnativa.com/>`_:
|
* `Tecnativa <https://www.tecnativa.com/>`_:
|
||||||
|
|
||||||
* Alexandre Díaz
|
* Alexandre Díaz
|
||||||
|
* Carlos Roca
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
@ -110,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_widget_numeric_step>`_ project on GitHub.
|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_widget_numeric_step>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
{
|
{
|
||||||
"name": "Web Widget Numeric Step",
|
"name": "Web Widget Numeric Step",
|
||||||
"category": "web",
|
"category": "web",
|
||||||
"version": "12.0.1.2.0",
|
"version": "13.0.1.0.0",
|
||||||
"author": "GRAP, Tecnativa, " "Odoo Community Association (OCA)",
|
"author": "GRAP, Tecnativa, " "Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"depends": ["web"],
|
"depends": ["web"],
|
||||||
"data": ["view/assets.xml"],
|
"data": ["view/assets.xml"],
|
||||||
"qweb": ["static/src/xml/numeric_step.xml",],
|
"qweb": ["static/src/xml/numeric_step.xml"],
|
||||||
"demo": ["demo/res_users_view.xml"],
|
"demo": ["demo/res_users_view.xml"],
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
* `Tecnativa <https://www.tecnativa.com/>`_:
|
* `Tecnativa <https://www.tecnativa.com/>`_:
|
||||||
|
|
||||||
* Alexandre Díaz
|
* Alexandre Díaz
|
||||||
|
* Carlos Roca
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
<title>Web Widget Numeric Step</title>
|
<title>Web Widget Numeric Step</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_numeric_step"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_numeric_step"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_widget_numeric_step"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_numeric_step"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This widget changes input number field and make it easier to increment the number thanks to 2 buttons (+ and -).
|
<p>This widget changes input number field and make it easier to increment the number thanks to 2 buttons (+ and -).
|
||||||
Use JS native logic for input number, so you can use the options <tt class="docutils literal">min</tt>, <tt class="docutils literal">max</tt>, <tt class="docutils literal">step</tt>, <tt class="docutils literal">placeholder</tt>.</p>
|
Use JS native logic for input number, so you can use the options <tt class="docutils literal">min</tt>, <tt class="docutils literal">max</tt>, <tt class="docutils literal">step</tt>, <tt class="docutils literal">placeholder</tt>.</p>
|
||||||
<p>Demo available at <cite>Settings > Users & Companies > Users > *Select One* > See ‘Credit Limit’ field</cite></p>
|
<p>Demo available at <cite>Settings > Users & Companies > Users > *Select One* > See ‘Credit Limit’ field</cite></p>
|
||||||
|
@ -390,7 +390,7 @@ Use JS native logic for input number, so you can use the options <tt class="docu
|
||||||
This will add the 2 buttons “+” and “-” just next to the input field in edit mode.
|
This will add the 2 buttons “+” and “-” just next to the input field in edit mode.
|
||||||
Iteration step by default is 1.</p>
|
Iteration step by default is 1.</p>
|
||||||
<div class="figure">
|
<div class="figure">
|
||||||
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/add_two_buttons.png" src="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/add_two_buttons.png" />
|
<img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/add_two_buttons.png" src="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/add_two_buttons.png" />
|
||||||
</div>
|
</div>
|
||||||
<p><strong>Optional</strong></p>
|
<p><strong>Optional</strong></p>
|
||||||
<p>Add an option to choose the step iteration and limits (min and max values).</p>
|
<p>Add an option to choose the step iteration and limits (min and max values).</p>
|
||||||
|
@ -402,11 +402,11 @@ Iteration step by default is 1.</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>
|
||||||
<div class="figure">
|
<div class="figure">
|
||||||
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step0,25andlimits.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step0,25andlimits.gif" />
|
<img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step0,25andlimits.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step0,25andlimits.gif" />
|
||||||
</div>
|
</div>
|
||||||
<p>Iteration with 10 step, max limit 15, placeholder with onchange</p>
|
<p>Iteration with 10 step, max limit 15, placeholder with onchange</p>
|
||||||
<div class="figure">
|
<div class="figure">
|
||||||
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif" />
|
<img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
|
@ -414,7 +414,7 @@ Iteration step by default is 1.</p>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
@ -435,6 +435,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference external" href="https://www.tecnativa.com/">Tecnativa</a>:<ul>
|
<li><a class="reference external" href="https://www.tecnativa.com/">Tecnativa</a>:<ul>
|
||||||
<li>Alexandre Díaz</li>
|
<li>Alexandre Díaz</li>
|
||||||
|
<li>Carlos Roca</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -446,7 +447,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_numeric_step">OCA/web</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_widget_numeric_step">OCA/web</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
odoo.define("web_widget_numeric_step.field", function(require) {
|
odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var field_utils = require("web.field_utils");
|
const field_utils = require("web.field_utils");
|
||||||
var Registry = require("web.field_registry");
|
const Registry = require("web.field_registry");
|
||||||
var FieldFloat = require("web.basic_fields").FieldFloat;
|
const FieldFloat = require("web.basic_fields").FieldFloat;
|
||||||
|
|
||||||
var NumericStep = FieldFloat.extend({
|
const NumericStep = FieldFloat.extend({
|
||||||
template: "web_widget_numeric_step",
|
template: "web_widget_numeric_step",
|
||||||
className: "o_field_numeric_step o_field_number",
|
className: "o_field_numeric_step o_field_number",
|
||||||
events: _.extend({}, _.omit(FieldFloat.prototype.events, ["change", "input"]), {
|
events: _.extend({}, _.omit(FieldFloat.prototype.events, ["change", "input"]), {
|
||||||
|
@ -38,8 +38,8 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
// Widget config
|
// Widget config
|
||||||
var max_val = this.nodeOptions.max;
|
let max_val = this.nodeOptions.max;
|
||||||
var min_val = this.nodeOptions.min;
|
let min_val = this.nodeOptions.min;
|
||||||
if (
|
if (
|
||||||
!_.isUndefined(min_val) &&
|
!_.isUndefined(min_val) &&
|
||||||
!_.isUndefined(max_val) &&
|
!_.isUndefined(max_val) &&
|
||||||
|
@ -55,10 +55,10 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
max: Number(max_val),
|
max: Number(max_val),
|
||||||
};
|
};
|
||||||
|
|
||||||
var self = this;
|
this._lazyOnChangeTrigger = _.debounce(
|
||||||
this._lazyOnChangeTrigger = _.debounce(function() {
|
() => this.$input.trigger("change"),
|
||||||
self.$input.trigger("change");
|
this.DELAY_THROTTLE_CHANGE
|
||||||
}, this.DELAY_THROTTLE_CHANGE);
|
);
|
||||||
this._auto_step_interval = false;
|
this._auto_step_interval = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -68,18 +68,13 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
|
||||||
this._click_delay = this.DEF_CLICK_DELAY;
|
this._click_delay = this.DEF_CLICK_DELAY;
|
||||||
this._autoStep = false;
|
this._autoStep = false;
|
||||||
return this._super.apply(this, arguments).then(function() {
|
return this._super.apply(this, arguments).then(() => {
|
||||||
document.addEventListener(
|
document.addEventListener("mouseup", this._onMouseUp.bind(this), false);
|
||||||
"mouseup",
|
|
||||||
$.proxy(self, "_onMouseUp"),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"touchend",
|
"touchend",
|
||||||
$.proxy(self, "_onMouseUp"),
|
this._onMouseUp.bind(this),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -103,7 +98,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_parseValue: function() {
|
_parseValue: function() {
|
||||||
var parsedVal = this._super.apply(this, arguments);
|
const parsedVal = this._super.apply(this, arguments);
|
||||||
if (this.mode === "edit") {
|
if (this.mode === "edit") {
|
||||||
return Number(parsedVal) || 0;
|
return Number(parsedVal) || 0;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +111,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_prepareInput: function() {
|
_prepareInput: function() {
|
||||||
var result = this._super.apply(this, arguments);
|
const result = this._super.apply(this, arguments);
|
||||||
this.$input.attr(_.pick(this.nodeOptions, ["placeholder"]));
|
this.$input.attr(_.pick(this.nodeOptions, ["placeholder"]));
|
||||||
// InputField hard set the input type to 'text' or 'password',
|
// InputField hard set the input type to 'text' or 'password',
|
||||||
// we force it again to be 'tel'.
|
// we force it again to be 'tel'.
|
||||||
|
@ -136,12 +131,10 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_renderEdit: function() {
|
_renderEdit: function() {
|
||||||
_.defer(
|
_.defer(() =>
|
||||||
function() {
|
this.$el
|
||||||
this.$el
|
.parents("td.o_numeric_step_cell")
|
||||||
.parents("td.o_numeric_step_cell")
|
.addClass("numeric_step_editing_cell")
|
||||||
.addClass("numeric_step_editing_cell");
|
|
||||||
}.bind(this)
|
|
||||||
);
|
);
|
||||||
this._prepareInput(this.$el.find("input.input_numeric_step"));
|
this._prepareInput(this.$el.find("input.input_numeric_step"));
|
||||||
},
|
},
|
||||||
|
@ -164,11 +157,11 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @param {String} mode can be "plus" or "minus"
|
* @param {String} mode can be "plus" or "minus"
|
||||||
*/
|
*/
|
||||||
_doStep: function(mode) {
|
_doStep: function(mode) {
|
||||||
var cval = 0;
|
let cval = 0;
|
||||||
try {
|
try {
|
||||||
var field = this.record.fields[this.name];
|
const field = this.record.fields[this.name];
|
||||||
cval = field_utils.parse[field.type](this.$input.val());
|
cval = field_utils.parse[field.type](this.$input.val());
|
||||||
} catch {
|
} catch (e) {
|
||||||
cval = this.value;
|
cval = this.value;
|
||||||
mode = false; // Only set the value in this case
|
mode = false; // Only set the value in this case
|
||||||
}
|
}
|
||||||
|
@ -177,7 +170,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
} else if (mode === "minus") {
|
} else if (mode === "minus") {
|
||||||
cval -= this._config.step;
|
cval -= this._config.step;
|
||||||
}
|
}
|
||||||
var nval = this._sanitizeNumberValue(cval);
|
const nval = this._sanitizeNumberValue(cval);
|
||||||
if (nval !== this.lastSetValue || !mode) {
|
if (nval !== this.lastSetValue || !mode) {
|
||||||
this.$input.val(nval);
|
this.$input.val(nval);
|
||||||
// Every time that user update the value we must trigger an
|
// Every time that user update the value we must trigger an
|
||||||
|
@ -203,7 +196,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
*/
|
*/
|
||||||
_onStepClick: function(ev) {
|
_onStepClick: function(ev) {
|
||||||
if (!this._autoStep) {
|
if (!this._autoStep) {
|
||||||
var mode = ev.target.dataset.mode;
|
const mode = ev.target.dataset.mode;
|
||||||
this._doStep(mode);
|
this._doStep(mode);
|
||||||
}
|
}
|
||||||
this._autoStep = false;
|
this._autoStep = false;
|
||||||
|
@ -216,7 +209,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
_onStepMouseDown: function(ev) {
|
_onStepMouseDown: function(ev) {
|
||||||
if (ev.button === 0 && !this._auto_step_interval) {
|
if (ev.button === 0 && !this._auto_step_interval) {
|
||||||
this._auto_step_interval = setTimeout(
|
this._auto_step_interval = setTimeout(
|
||||||
$.proxy(this, "_whileMouseDown", ev),
|
this._whileMouseDown.bind(this, ev),
|
||||||
this._click_delay
|
this._click_delay
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +219,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @param {FocusoutEvent} ev
|
* @param {FocusoutEvent} ev
|
||||||
*/
|
*/
|
||||||
_onFocusOut: function(evt) {
|
_onFocusOut: function() {
|
||||||
if (this._auto_step_interval) {
|
if (this._auto_step_interval) {
|
||||||
this._clearStepInterval();
|
this._clearStepInterval();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +238,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
*/
|
*/
|
||||||
_whileMouseDown: function(ev) {
|
_whileMouseDown: function(ev) {
|
||||||
this._autoStep = true;
|
this._autoStep = true;
|
||||||
var mode = ev.target.dataset.mode;
|
const mode = ev.target.dataset.mode;
|
||||||
this._doStep(mode);
|
this._doStep(mode);
|
||||||
if (this._click_delay > this.MIN_DELAY) {
|
if (this._click_delay > this.MIN_DELAY) {
|
||||||
this._click_delay -= this.SUBSTRACT_DELAY_STEP;
|
this._click_delay -= this.SUBSTRACT_DELAY_STEP;
|
||||||
|
@ -302,7 +295,7 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
_sanitizeNumberValue: function(value) {
|
_sanitizeNumberValue: function(value) {
|
||||||
var cval = Number(value);
|
let cval = Number(value);
|
||||||
if (_.isNaN(cval)) {
|
if (_.isNaN(cval)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -312,14 +305,14 @@ odoo.define("web_widget_numeric_step.field", function(require) {
|
||||||
cval = this._config.max;
|
cval = this._config.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
var field = this.record.fields[this.name];
|
const field = this.record.fields[this.name];
|
||||||
var formattedValue = field_utils.format[field.type](cval, field, {
|
// Formatted value
|
||||||
|
return field_utils.format[field.type](cval, field, {
|
||||||
data: this.record.data,
|
data: this.record.data,
|
||||||
escape: true,
|
escape: true,
|
||||||
isPassword: false,
|
isPassword: false,
|
||||||
digits: field.digits,
|
digits: field.digits,
|
||||||
});
|
});
|
||||||
return formattedValue;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue