Commit 5fdc383e1b83fccd4552e2c2798a9412ba5efd42
1 parent
2f61f3e5
Exists in
master
and in
13 other branches
#11199-Done
Showing
3 changed files
with
41 additions
and
6 deletions
Show diff stats
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
... | ... | @@ -13,6 +13,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
13 | 13 | extend: 'Ext.window.Window', // This class extends from Ext.window.Window |
14 | 14 | // Window configurations |
15 | 15 | x: 0, y: 0, // The initial position of the window |
16 | + requires:['amdaUI.StandardFloatField'], | |
16 | 17 | title: 'Interval Selection', // The title of the window |
17 | 18 | constrain: true, // Constrains the window to within the boundaries of its containing element |
18 | 19 | collapsible: true, // Allows the window to be collapsed |
... | ... | @@ -66,9 +67,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
66 | 67 | if (newValue === null || newValue === undefined || newValue === '') return; |
67 | 68 | var field2 = self._getField2(); |
68 | 69 | // Check if field2 is not empty |
69 | - const value2 = field2.getValue(); | |
70 | + const value2 = parseFloat(field2.getValue()); | |
70 | 71 | if (value2 !== null && value2 !== undefined && value2 !== '') { |
71 | - if (newValue > value2) { | |
72 | + if (parseFloat(newValue) > value2) { | |
72 | 73 | // Update both field1 and field2 to the new values |
73 | 74 | field2.suspendEvents(); |
74 | 75 | field2.setValue(newValue); |
... | ... | @@ -89,9 +90,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
89 | 90 | if (newValue === null || newValue === undefined || newValue === '') return; |
90 | 91 | var field1 = self._getField1(); |
91 | 92 | // Check if field1 is not empty |
92 | - const value1 = field1.getValue(); | |
93 | + const value1 = parseFloat(field1.getValue()); | |
93 | 94 | if (value1 !== null && value1 !== undefined && value1 !== '') { |
94 | - if (newValue < value1) { | |
95 | + if (parseFloat(newValue) < value1) { | |
95 | 96 | // Update both field1 and field2 to the new values |
96 | 97 | field1.suspendEvents(); |
97 | 98 | field1.setValue(newValue); | ... | ... |
js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js
1 | 1 | Ext.define('amdaPlotComp.intervalSelection.NumberZoomIntervalSelection', { |
2 | 2 | extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', // This class extends from amdaPlotComp.intervalSelection.ZoomIntervalSelection |
3 | 3 | |
4 | - field1Type: 'numberfield', // The type of the first field is a number field | |
4 | + field1Type: 'standardfloatfield', // The type of the first field is a number field | |
5 | 5 | field1Label: 'Min Value', // The label for the first field is 'Min Value' |
6 | 6 | field1Format: null, // The format for the first field is initially set to null |
7 | - field2Type: 'numberfield', // The type of the second field is a number field | |
7 | + field2Type: 'standardfloatfield', // The type of the second field is a number field | |
8 | 8 | field2Label: 'Max value', // The label for the second field is 'Max value' |
9 | 9 | field2Format: null, // The format for the second field is initially set to null |
10 | 10 | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +Ext.define('amdaUI.StandardFloatField', { | |
2 | + extend: 'Ext.form.field.Text', | |
3 | + | |
4 | + xtype: 'standardfloatfield', | |
5 | + | |
6 | + // Additional configurations and custom logic can be added here | |
7 | + regex: /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/, | |
8 | + min:-Number.MAX_VALUE, | |
9 | + max: Number.MAX_VALUE, | |
10 | + | |
11 | + initComponent: function () { | |
12 | + this.callParent(); | |
13 | + | |
14 | + // Set up validation and change event handling | |
15 | + this.validator = this.createValidator(); | |
16 | + }, | |
17 | + | |
18 | + createValidator: function () { | |
19 | + var me = this; | |
20 | + | |
21 | + return function (val) { | |
22 | + var errMsg = null; | |
23 | + if (!me.allowBlank && Ext.isEmpty(val)) { | |
24 | + errMsg = 'Blank value not allowed'; | |
25 | + } else if ((typeof me.min !== 'undefined' && me.min !== null) && (parseFloat(val) < me.min)) { | |
26 | + errMsg = 'Min. allowed value is ' + me.min; | |
27 | + } else if ((typeof me.max !== 'undefined' && me.max !== null) && (parseFloat(val) > me.max)) { | |
28 | + errMsg = 'Max. allowed value is ' + me.max; | |
29 | + } | |
30 | + | |
31 | + return errMsg ? errMsg : true; | |
32 | + }; | |
33 | + }, | |
34 | +}); | ... | ... |