@@ -113,6 +113,14 @@ export const filterModeText = (newMode: FilterMode, type: string) => {
113
113
verb : type === "date" ? "are before" : "are less than" ,
114
114
afterVerb : type === "string" ? "characters long" : "" ,
115
115
} ,
116
+ {
117
+ mode : FilterMode . STARTSWITH ,
118
+ verb : "start with" ,
119
+ } ,
120
+ {
121
+ mode : FilterMode . ENDSWITH ,
122
+ verb : "end with" ,
123
+ }
116
124
]
117
125
118
126
return {
@@ -142,6 +150,10 @@ export enum FilterMode {
142
150
EXACT = "match" ,
143
151
// string: any no exact match, int: != value, groups: exclude members in all groups
144
152
NOTEXACT = "no match" ,
153
+ // string: starts with, int: N/A, groups: N/A
154
+ STARTSWITH = "starts with" ,
155
+ // string: ends with, int: N/A, groups N/A
156
+ ENDSWITH = "ends with"
145
157
}
146
158
147
159
export const groupArrayModes = [
@@ -405,6 +417,22 @@ function applyFilter<T>(list: T[], filter: Filter, groupList?: Group[]): T[] {
405
417
} else return false
406
418
} )
407
419
break
420
+ case FilterMode . STARTSWITH :
421
+ processedList = processedList . filter ( ( i ) => {
422
+ if ( ! value ) return true
423
+ if ( ! i [ field ] ) return false
424
+ if ( typeof i [ field ] !== "string" ) return true
425
+ return ( i [ field ] as string ) . startsWith ( value as string )
426
+ } )
427
+ break
428
+ case FilterMode . ENDSWITH :
429
+ processedList = processedList . filter ( ( i ) => {
430
+ if ( ! value ) return true
431
+ if ( ! i [ field ] ) return false
432
+ if ( typeof i [ field ] !== "string" ) return true
433
+ return ( i [ field ] as string ) . endsWith ( value as string )
434
+ } )
435
+ break
408
436
}
409
437
return processedList
410
438
}
0 commit comments