@@ -57,8 +57,9 @@ export class SearchParametersDialogComponent {
57
57
add = ( ) : void => {
58
58
const { lhs, relation, unit } = this . parametersForm . value ;
59
59
const rawRhs = this . parametersForm . get ( "rhs" ) ?. value ;
60
- const rhs =
61
- relation === "EQUAL_TO_STRING" ? String ( rawRhs ) : Number ( rawRhs ) ;
60
+ const rhs = [ "CONTAINS_STRING" , "EQUAL_TO_STRING" ] . includes ( relation )
61
+ ? String ( rawRhs )
62
+ : Number ( rawRhs ) ;
62
63
this . parametersForm . patchValue ( { rhs } ) ;
63
64
this . dialogRef . close ( { data : { lhs, relation, rhs, unit } } ) ;
64
65
} ;
@@ -73,7 +74,11 @@ export class SearchParametersDialogComponent {
73
74
toggleUnitField = ( ) : void => {
74
75
const lhsInvalid = this . parametersForm . get ( "lhs" ) ?. invalid ;
75
76
const { relation } = this . parametersForm . value ;
76
- const isStringRelation = relation === "EQUAL_TO_STRING" ? true : false ;
77
+ const isStringRelation = [ "CONTAINS_STRING" , "EQUAL_TO_STRING" ] . includes (
78
+ relation ,
79
+ )
80
+ ? true
81
+ : false ;
77
82
const unitField = this . parametersForm . get ( "unit" ) ;
78
83
unitField ?. enable ( ) ;
79
84
if ( lhsInvalid || isStringRelation ) {
@@ -88,7 +93,10 @@ export class SearchParametersDialogComponent {
88
93
if ( invalid ) {
89
94
return invalid ;
90
95
}
91
- if ( relation !== "EQUAL_TO_STRING" && isNaN ( Number ( rhs ) ) ) {
96
+ if (
97
+ ! [ "CONTAINS_STRING" , "EQUAL_TO_STRING" ] . includes ( relation ) &&
98
+ isNaN ( Number ( rhs ) )
99
+ ) {
92
100
return true ;
93
101
}
94
102
return lhs . length * ( rhs as string ) . length === 0 ;
0 commit comments