File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,16 @@ import stringCompare from 'lib/stringCompare';
13
13
import { CurrentApp } from 'context/currentApp' ;
14
14
15
15
function changeField ( schema , filters , index , newField ) {
16
- let newFilter = new Map ( {
16
+ const allowedConstraints = Filters . FieldConstraints [ schema [ newField ] . type ] ;
17
+ const current = filters . get ( index ) ;
18
+ const constraint = current . get ( 'constraint' ) ;
19
+ const compare = current . get ( 'compareTo' ) ;
20
+ const defaultCompare = Filters . DefaultComparisons [ schema [ newField ] . type ] ;
21
+ const useExisting = allowedConstraints . includes ( constraint ) ;
22
+ const newFilter = new Map ( {
17
23
field : newField ,
18
- constraint : Filters . FieldConstraints [ schema [ newField ] . type ] [ 0 ] ,
19
- compareTo : Filters . DefaultComparisons [ schema [ newField ] . type ]
24
+ constraint : useExisting ? constraint : Filters . FieldConstraints [ schema [ newField ] . type ] [ 0 ] ,
25
+ compareTo : ( useExisting && typeof defaultCompare === typeof compare ) ? compare : defaultCompare
20
26
} ) ;
21
27
return filters . set ( index , newFilter ) ;
22
28
}
You can’t perform that action at this time.
0 commit comments