@@ -5,66 +5,77 @@ export const booleanOptions = [
55 { value : 'false' , label : 'False' } ,
66] ;
77
8+ const nullOperators = [
9+ { value : 'IS NULL' , label : 'is empty' } ,
10+ { value : 'IS NOT NULL' , label : 'is not empty' } ,
11+ ] ;
12+
13+ const withNullOperators = ( operators ) => [ ...operators , ...nullOperators ] ;
14+
815export const operatorsByType = {
9- text : [
16+ text : withNullOperators ( [
1017 { value : '=' , label : 'equals' } ,
1118 { value : '!=' , label : 'does not equal' } ,
1219 { value : '~' , label : 'contains' } ,
13- ] ,
14- number : [
20+ ] ) ,
21+ number : withNullOperators ( [
1522 { value : '=' , label : 'equals' } ,
1623 { value : '!=' , label : 'does not equal' } ,
1724 { value : '<' , label : 'less than' } ,
1825 { value : '<=' , label : 'less than or equal' } ,
1926 { value : '>' , label : 'greater than' } ,
2027 { value : '>=' , label : 'greater than or equal' } ,
21- ] ,
22- date : [
28+ ] ) ,
29+ date : withNullOperators ( [
2330 { value : '=' , label : 'on' } ,
2431 { value : '!=' , label : 'not on' } ,
2532 { value : '<' , label : 'before' } ,
2633 { value : '<=' , label : 'on or before' } ,
2734 { value : '>' , label : 'after' } ,
2835 { value : '>=' , label : 'on or after' } ,
29- ] ,
30- enum : [
36+ ] ) ,
37+ enum : withNullOperators ( [
3138 { value : '=' , label : 'is' } ,
3239 { value : '!=' , label : 'is not' } ,
3340 { value : 'IN' , label : 'is one of' } ,
3441 { value : 'NOT IN' , label : 'is not one of' } ,
35- ] ,
36- select : [
42+ ] ) ,
43+ select : withNullOperators ( [
3744 { value : '=' , label : 'is' } ,
3845 { value : '!=' , label : 'is not' } ,
3946 { value : 'IN' , label : 'is one of' } ,
4047 { value : 'NOT IN' , label : 'is not one of' } ,
41- ] ,
42- boolean : [ { value : '=' , label : 'is' } ] ,
43- user : [
48+ ] ) ,
49+ boolean : withNullOperators ( [ { value : '=' , label : 'is' } ] ) ,
50+ user : withNullOperators ( [
4451 { value : '=' , label : 'is' } ,
4552 { value : '!=' , label : 'is not' } ,
4653 { value : 'IN' , label : 'is one of' } ,
4754 { value : 'NOT IN' , label : 'is not one of' } ,
48- ] ,
49- textarea : [
55+ ] ) ,
56+ textarea : withNullOperators ( [
5057 { value : '=' , label : 'equals' } ,
5158 { value : '!=' , label : 'does not equal' } ,
5259 { value : '~' , label : 'contains' } ,
53- ] ,
54- reference : [
60+ ] ) ,
61+ reference : withNullOperators ( [
5562 { value : '=' , label : 'is' } ,
5663 { value : '!=' , label : 'is not' } ,
5764 { value : 'IN' , label : 'is one of' } ,
5865 { value : 'NOT IN' , label : 'is not one of' } ,
59- ] ,
60- identifier : [
66+ ] ) ,
67+ identifier : withNullOperators ( [
6168 { value : '=' , label : 'equals' } ,
6269 { value : '!=' , label : 'does not equal' } ,
6370 { value : 'IN' , label : 'is one of' } ,
6471 { value : 'NOT IN' , label : 'is not one of' } ,
65- ] ,
72+ ] ) ,
6673} ;
6774
6875export function isMultiValueOperator ( operator ) {
6976 return operator === 'IN' || operator === 'NOT IN' ;
7077}
78+
79+ export function isNullOperator ( operator ) {
80+ return operator === 'IS NULL' || operator === 'IS NOT NULL' ;
81+ }
0 commit comments