Commit 3bda2729ed577619a9bf00efcacd979f04ed42a8

Authored by Menouar AZIB
1 parent a75892d1

Fix some unwanted behaviors on zoom fields.

js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
@@ -60,7 +60,24 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { @@ -60,7 +60,24 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', {
60 xtype: this.field1Type, 60 xtype: this.field1Type,
61 fieldLabel: this.field1Label, 61 fieldLabel: this.field1Label,
62 itemId: this.FIELD1_ITEM_ID, 62 itemId: this.FIELD1_ITEM_ID,
63 - format: this.field1Format 63 + format: this.field1Format,
  64 + listeners: {
  65 + change: function (field, newValue) {
  66 + if (newValue === null || newValue === undefined || newValue === '') return;
  67 + var field2 = me._getField2();
  68 + // Check if field2 is not empty
  69 + const value2 = field2.getValue();
  70 + if (value2 !== null && value2 !== undefined && value2 !== '') {
  71 + if (newValue > value2) {
  72 + // Update both field1 and field2 to the new values
  73 + field2.suspendEvents();
  74 + field2.setValue(newValue);
  75 + field.setValue(value2);
  76 + field2.resumeEvents();
  77 + }
  78 + }
  79 + }
  80 + }
64 }, 81 },
65 { 82 {
66 xtype: this.field2Type, 83 xtype: this.field2Type,
@@ -69,14 +86,17 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { @@ -69,14 +86,17 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', {
69 format: this.field2Format, 86 format: this.field2Format,
70 listeners: { 87 listeners: {
71 change: function (field, newValue) { 88 change: function (field, newValue) {
  89 + if (newValue === null || newValue === undefined || newValue === '') return;
72 var field1 = me._getField1(); 90 var field1 = me._getField1();
73 // Check if field1 is not empty 91 // Check if field1 is not empty
74 const value1 = field1.getValue(); 92 const value1 = field1.getValue();
75 if (value1 !== null && value1 !== undefined && value1 !== '') { 93 if (value1 !== null && value1 !== undefined && value1 !== '') {
76 if (newValue < value1) { 94 if (newValue < value1) {
77 // Update both field1 and field2 to the new values 95 // Update both field1 and field2 to the new values
  96 + field1.suspendEvents();
78 field1.setValue(newValue); 97 field1.setValue(newValue);
79 field.setValue(value1); 98 field.setValue(value1);
  99 + field1.resumeEvents();
80 } 100 }
81 } 101 }
82 } 102 }