Commit afb7b4643d41e67919101ee2c77f69618a4c5e45

Authored by Benjamin Renard
1 parent 23fba7a9

Fix decimal precision for axis range (#6193)

js/app/views/PlotComponents/PlotBaseAxisForm.js
... ... @@ -18,8 +18,8 @@ Ext.define('amdaPlotComp.PlotBaseAxisForm', {
18 18  
19 19 getFormItems: function() {
20 20 var rangeItems = [
21   - this.addStandardFloat('axis-range-min', 'Min', -Number.MAX_VALUE, Number.MAX_VALUE),
22   - this.addStandardFloat('axis-range-max', 'Max', -Number.MAX_VALUE, Number.MAX_VALUE),
  21 + this.addStandardFloat2('axis-range-min', 'Min', -Number.MAX_VALUE, Number.MAX_VALUE),
  22 + this.addStandardFloat2('axis-range-max', 'Max', -Number.MAX_VALUE, Number.MAX_VALUE),
23 23 this.addStandardCheck('axis-range-extend', 'Extend Axis Range')
24 24 ];
25 25  
... ... @@ -51,4 +51,4 @@ Ext.define('amdaPlotComp.PlotBaseAxisForm', {
51 51  
52 52 return axisItems;
53 53 }
54   -});
55 54 \ No newline at end of file
  55 +});
... ...
js/app/views/PlotComponents/PlotBaseSerieForm.js
... ... @@ -77,8 +77,8 @@ Ext.define('amdaPlotComp.PlotBaseSerieForm', {
77 77  
78 78 getValuesRangeItems: function() {
79 79 return [
80   - this.addStandardFloat('serie-value-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
81   - this.addStandardFloat('serie-value-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
  80 + this.addStandardFloat2('serie-value-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
  81 + this.addStandardFloat2('serie-value-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
82 82 ];
83 83 },
84 84  
... ... @@ -98,4 +98,4 @@ Ext.define('amdaPlotComp.PlotBaseSerieForm', {
98 98 this.addStandardFieldSet('Interval ticks', 'serie-intervaltick-activated', this.getIntervalTickItems())
99 99 ];
100 100 }
101   -});
102 101 \ No newline at end of file
  102 +});
... ...
js/app/views/PlotComponents/PlotSerieForm.js
... ... @@ -58,8 +58,8 @@ Ext.define('amdaPlotComp.PlotSerieForm', {
58 58  
59 59 getXValuesRangeItems: function() {
60 60 return [
61   - this.addStandardFloat('serie-xvalue-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
62   - this.addStandardFloat('serie-xvalue-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
  61 + this.addStandardFloat2('serie-xvalue-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
  62 + this.addStandardFloat2('serie-xvalue-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
63 63 ];
64 64 },
65 65  
... ... @@ -85,4 +85,4 @@ Ext.define('amdaPlotComp.PlotSerieForm', {
85 85  
86 86 return serieItems;
87 87 }
88   -});
89 88 \ No newline at end of file
  89 +});
... ...
js/app/views/PlotComponents/PlotSpectroForm.js
... ... @@ -18,8 +18,8 @@ Ext.define('amdaPlotComp.PlotSpectroForm', {
18 18  
19 19 getValuesRangeItems: function() {
20 20 return [
21   - this.addStandardFloat('spectro-value-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
22   - this.addStandardFloat('spectro-value-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
  21 + this.addStandardFloat2('spectro-value-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
  22 + this.addStandardFloat2('spectro-value-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
23 23 ];
24 24 },
25 25  
... ... @@ -33,4 +33,4 @@ Ext.define('amdaPlotComp.PlotSpectroForm', {
33 33 this.addStandardFieldSet('Min/Max thresholds', '', this.getValuesRangeItems())
34 34 ];
35 35 }
36   -});
37 36 \ No newline at end of file
  37 +});
... ...
js/app/views/PlotComponents/PlotStandardForm.js
... ... @@ -81,6 +81,39 @@ Ext.define('amdaPlotComp.PlotStandardForm', {
81 81 }
82 82 };
83 83 },
  84 +
  85 + addStandardFloat2: function(name, label, min, max, allowBlank, onChange) {
  86 + allowBlank = (typeof allowBlank !== 'undefined') ? allowBlank : false;
  87 +
  88 + return {
  89 + xtype: 'textfield',
  90 + name: name,
  91 + fieldLabel: label,
  92 + regex : /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/,
  93 + validator: function (val) {
  94 + var errMsg = null;
  95 + if (!allowBlank && Ext.isEmpty(val)) {
  96 + errMsg = 'Blank value not allowed';
  97 + }
  98 + else if ((typeof min !== 'undefined') && (parseFloat(val) < min)) {
  99 + errMsg = 'Min. allowed value is ' + min;
  100 + }
  101 + else if ((typeof max !== 'undefined') && (parseFloat(val) > max)) {
  102 + errMsg = 'Max. allowed value is ' + max;
  103 + }
  104 +
  105 + return errMsg ? errMsg : true;
  106 + },
  107 + listeners: {
  108 + change: function(field, newValue, oldValue, eOpts) {
  109 + this.object.set(name, newValue);
  110 + if (onChange != null)
  111 + onChange(name, newValue, oldValue);
  112 + },
  113 + scope: this
  114 + }
  115 + };
  116 + },
84 117  
85 118 addStandardCombo: function(name, label, availableData, onChange) {
86 119 var comboStore = Ext.create('Ext.data.Store', {
... ...