File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 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';
1313import { CurrentApp } from 'context/currentApp' ;
1414
1515function 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 ( {
1723 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
2026 } ) ;
2127 return filters . set ( index , newFilter ) ;
2228}
You can’t perform that action at this time.
0 commit comments