Commit 3bda2729ed577619a9bf00efcacd979f04ed42a8
1 parent
a75892d1
Exists in
master
and in
16 other branches
Fix some unwanted behaviors on zoom fields.
Showing
1 changed file
with
21 additions
and
1 deletions
Show diff stats
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
... | ... | @@ -60,7 +60,24 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
60 | 60 | xtype: this.field1Type, |
61 | 61 | fieldLabel: this.field1Label, |
62 | 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 | 83 | xtype: this.field2Type, |
... | ... | @@ -69,14 +86,17 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
69 | 86 | format: this.field2Format, |
70 | 87 | listeners: { |
71 | 88 | change: function (field, newValue) { |
89 | + if (newValue === null || newValue === undefined || newValue === '') return; | |
72 | 90 | var field1 = me._getField1(); |
73 | 91 | // Check if field1 is not empty |
74 | 92 | const value1 = field1.getValue(); |
75 | 93 | if (value1 !== null && value1 !== undefined && value1 !== '') { |
76 | 94 | if (newValue < value1) { |
77 | 95 | // Update both field1 and field2 to the new values |
96 | + field1.suspendEvents(); | |
78 | 97 | field1.setValue(newValue); |
79 | 98 | field.setValue(value1); |
99 | + field1.resumeEvents(); | |
80 | 100 | } |
81 | 101 | } |
82 | 102 | } | ... | ... |