diff --git a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js index c70442b..83323be 100644 --- a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js @@ -13,6 +13,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { extend: 'Ext.window.Window', // This class extends from Ext.window.Window // Window configurations x: 0, y: 0, // The initial position of the window + requires:['amdaUI.StandardFloatField'], title: 'Interval Selection', // The title of the window constrain: true, // Constrains the window to within the boundaries of its containing element collapsible: true, // Allows the window to be collapsed @@ -66,9 +67,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { if (newValue === null || newValue === undefined || newValue === '') return; var field2 = self._getField2(); // Check if field2 is not empty - const value2 = field2.getValue(); + const value2 = parseFloat(field2.getValue()); if (value2 !== null && value2 !== undefined && value2 !== '') { - if (newValue > value2) { + if (parseFloat(newValue) > value2) { // Update both field1 and field2 to the new values field2.suspendEvents(); field2.setValue(newValue); @@ -89,9 +90,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { if (newValue === null || newValue === undefined || newValue === '') return; var field1 = self._getField1(); // Check if field1 is not empty - const value1 = field1.getValue(); + const value1 = parseFloat(field1.getValue()); if (value1 !== null && value1 !== undefined && value1 !== '') { - if (newValue < value1) { + if (parseFloat(newValue) < value1) { // Update both field1 and field2 to the new values field1.suspendEvents(); field1.setValue(newValue); diff --git a/js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js index dabae4b..2f78161 100644 --- a/js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js @@ -1,10 +1,10 @@ Ext.define('amdaPlotComp.intervalSelection.NumberZoomIntervalSelection', { extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', // This class extends from amdaPlotComp.intervalSelection.ZoomIntervalSelection - field1Type: 'numberfield', // The type of the first field is a number field + field1Type: 'standardfloatfield', // The type of the first field is a number field field1Label: 'Min Value', // The label for the first field is 'Min Value' field1Format: null, // The format for the first field is initially set to null - field2Type: 'numberfield', // The type of the second field is a number field + field2Type: 'standardfloatfield', // The type of the second field is a number field field2Label: 'Max value', // The label for the second field is 'Max value' field2Format: null, // The format for the second field is initially set to null diff --git a/js/app/views/StandardFloatField.js b/js/app/views/StandardFloatField.js new file mode 100644 index 0000000..8e47915 --- /dev/null +++ b/js/app/views/StandardFloatField.js @@ -0,0 +1,34 @@ +Ext.define('amdaUI.StandardFloatField', { + extend: 'Ext.form.field.Text', + + xtype: 'standardfloatfield', + + // Additional configurations and custom logic can be added here + regex: /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/, + min:-Number.MAX_VALUE, + max: Number.MAX_VALUE, + + initComponent: function () { + this.callParent(); + + // Set up validation and change event handling + this.validator = this.createValidator(); + }, + + createValidator: function () { + var me = this; + + return function (val) { + var errMsg = null; + if (!me.allowBlank && Ext.isEmpty(val)) { + errMsg = 'Blank value not allowed'; + } else if ((typeof me.min !== 'undefined' && me.min !== null) && (parseFloat(val) < me.min)) { + errMsg = 'Min. allowed value is ' + me.min; + } else if ((typeof me.max !== 'undefined' && me.max !== null) && (parseFloat(val) > me.max)) { + errMsg = 'Max. allowed value is ' + me.max; + } + + return errMsg ? errMsg : true; + }; + }, +}); -- libgit2 0.21.2