diff --git a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js index a610917..27eb0d2 100644 --- a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js @@ -60,7 +60,24 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { xtype: this.field1Type, fieldLabel: this.field1Label, itemId: this.FIELD1_ITEM_ID, - format: this.field1Format + format: this.field1Format, + listeners: { + change: function (field, newValue) { + if (newValue === null || newValue === undefined || newValue === '') return; + var field2 = me._getField2(); + // Check if field2 is not empty + const value2 = field2.getValue(); + if (value2 !== null && value2 !== undefined && value2 !== '') { + if (newValue > value2) { + // Update both field1 and field2 to the new values + field2.suspendEvents(); + field2.setValue(newValue); + field.setValue(value2); + field2.resumeEvents(); + } + } + } + } }, { xtype: this.field2Type, @@ -69,14 +86,17 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { format: this.field2Format, listeners: { change: function (field, newValue) { + if (newValue === null || newValue === undefined || newValue === '') return; var field1 = me._getField1(); // Check if field1 is not empty const value1 = field1.getValue(); if (value1 !== null && value1 !== undefined && value1 !== '') { if (newValue < value1) { // Update both field1 and field2 to the new values + field1.suspendEvents(); field1.setValue(newValue); field.setValue(value1); + field1.resumeEvents(); } } } -- libgit2 0.21.2