@@ -113,6 +113,14 @@ export const filterModeText = (newMode: FilterMode, type: string) => {
113113 verb : type === "date" ? "are before" : "are less than" ,
114114 afterVerb : type === "string" ? "characters long" : "" ,
115115 } ,
116+ {
117+ mode : FilterMode . STARTSWITH ,
118+ verb : "start with" ,
119+ } ,
120+ {
121+ mode : FilterMode . ENDSWITH ,
122+ verb : "end with" ,
123+ }
116124 ]
117125
118126 return {
@@ -142,6 +150,10 @@ export enum FilterMode {
142150 EXACT = "match" ,
143151 // string: any no exact match, int: != value, groups: exclude members in all groups
144152 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"
145157}
146158
147159export const groupArrayModes = [
@@ -405,6 +417,22 @@ function applyFilter<T>(list: T[], filter: Filter, groupList?: Group[]): T[] {
405417 } else return false
406418 } )
407419 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
408436 }
409437 return processedList
410438}
0 commit comments