Skip to content

Commit 62ac6e8

Browse files
committed
Use TypeaheadFilter with ** operator for project selector search
Separate the ~ (contains) and ** (everywhere/typeahead) operator paths in NameFilter: ~ keeps single-substring LIKE behavior for explicit user-facing filters; ** now splits on whitespace and ANDs all tokens, enabling multi-term search. Switch SearchableProjectListService from ['name', '~', ...] to ['typeahead', '**', ...] so the project selector routes through TypeaheadFilter, which inherits the multi-term ** behavior automatically.
1 parent 6024c23 commit 62ac6e8

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/models/queries/projects/filters/name_filter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def where
3939
["LOWER(projects.name) IN (?)", sql_value]
4040
when "!"
4141
["LOWER(projects.name) NOT IN (?)", sql_value]
42-
when "~", "**"
42+
when "~"
43+
["LOWER(projects.name) LIKE ?", "%#{sql_value}%"]
44+
when "**"
4345
terms = values.first.downcase.split
4446
conditions = Array.new(terms.size, "LOWER(projects.name) LIKE ?").join(" AND ")
4547
[conditions, *terms.map { |t| "%#{t}%" }]

frontend/src/app/shared/components/searchable-project-list/searchable-project-list.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ export class SearchableProjectListService {
8484
return of([[] as IProject[], searchText, loadingEnabled as boolean, favoriteIds]);
8585
}
8686

87-
const nameFilter:ApiV3ListFilter[] = [];
87+
const searchFilter:ApiV3ListFilter[] = [];
8888
if (searchText.length > 0) {
89-
nameFilter.push(['name', '~', [searchText]]);
89+
searchFilter.push(['typeahead', '**', [searchText]]);
9090
}
9191

92-
return this.fetchProjects(nameFilter)
92+
return this.fetchProjects(searchFilter)
9393
.pipe(map((collection) => [collection._embedded.elements, searchText, loadingEnabled as boolean, favoriteIds]));
9494
}),
9595
switchMap(([projects, searchText, loadingEnabled, favoriteIds]:[IProject[],string,boolean,string[]]) => {

0 commit comments

Comments
 (0)