From 1ddd5b23d5327480bbbe1be97f2b71c8000c7a52 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 30 Oct 2020 20:15:50 +0300 Subject: [PATCH] MetricSpinner: fix check auto value --- .../main/lib/component/MetricSpinner.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/MetricSpinner.js b/apps/common/main/lib/component/MetricSpinner.js index b90673569..6f69c9217 100644 --- a/apps/common/main/lib/component/MetricSpinner.js +++ b/apps/common/main/lib/component/MetricSpinner.js @@ -234,10 +234,7 @@ define([ }, getNumberValue: function(){ - if (this.options.allowAuto && this.value==this.options.autoText) - return -1; - else - return parseFloat(this.value); + return this.checkAutoText(this.value) ? -1 : parseFloat(this.value); }, getUnitValue: function(){ @@ -262,7 +259,7 @@ define([ this.lastValue = this.value; if ( typeof value === 'undefined' || value === ''){ this.value = ''; - } else if (this.options.allowAuto && (Math.abs(Common.Utils.String.parseFloat(value)+1.)<0.0001 || value==this.options.autoText)) { + } else if (this.options.allowAuto && (Math.abs(Common.Utils.String.parseFloat(value)+1.)<0.0001 || this.checkAutoText(value))) { this.value = this.options.autoText; } else { var number = this._add(Common.Utils.String.parseFloat(value), 0, (this.options.allowDecimal) ? 3 : 0); @@ -450,7 +447,7 @@ define([ val = this.getRawValue(); val = _.isEmpty(val) ? me.oldValue : Common.Utils.String.parseFloat(val); } else if(me.getValue() !== '') { - if (me.options.allowAuto && me.getValue()==me.options.autoText) { + if (me.checkAutoText(me.getValue())) { val = me.options.minValue-me.options.step; } else val = Common.Utils.String.parseFloat(me.getValue()); @@ -471,7 +468,7 @@ define([ val = this.getRawValue(); val = _.isEmpty(val) ? me.oldValue : Common.Utils.String.parseFloat(val); } else if(me.getValue() !== '') { - if (me.options.allowAuto && me.getValue()==me.options.autoText) { + if (me.checkAutoText(me.getValue())) { val = me.options.minValue; } else val = Common.Utils.String.parseFloat(me.getValue()); @@ -537,6 +534,14 @@ define([ v_out = parseFloat((v_out * 6.0 / 25.4).toFixed(6)); return v_out; + }, + + checkAutoText: function(value) { + if (this.options.allowAuto && typeof value == 'string') { + var val = value.toLowerCase(); + return (val==this.options.autoText.toLowerCase() || val=='auto'); + } + return false; } });