Merge pull request #8174 from opf/fix/watcher_filter_reset

Fix/watcher filter reset
pull/8188/head
Oliver Günther 5 years ago committed by GitHub
commit b6211f6977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      frontend/src/app/components/api/api-v3/api-v3-filter-builder.ts
  2. 10
      frontend/src/app/modules/common/autocomplete/user-autocompleter.component.ts

@ -58,10 +58,22 @@ export class ApiV3FilterBuilder {
return this.serializeFilter(filter);
});
let params = { filters: `[${transformedFilters.join(",")}]`, ...mergeParams }
let params = { filters: `[${transformedFilters.join(",")}]`, ...mergeParams };
return new URLSearchParams(params).toString();
}
public clone() {
let newFilters = new ApiV3FilterBuilder();
this.filters.forEach(filter => {
Object.keys(filter).forEach(name => {
newFilters.add(name, filter[name].operator, filter[name].values);
});
});
return newFilters;
}
private serializeFilter(filter:ApiV3Filter) {
let transformedFilter:string;
let keys:Array<string>;

@ -116,7 +116,9 @@ export class UserAutocompleterComponent implements OnInit {
}
public onFocus() {
this.requests.input$.next('');
if (!this.requests.lastRequestedValue) {
this.requests.input$.next('');
}
}
public onModelChange(user:any) {
@ -135,9 +137,11 @@ export class UserAutocompleterComponent implements OnInit {
}
private getAvailableUsers(url:string, searchTerm:any):Observable<{[key:string]:string|null}[]> {
let searchFilters = this.inputFilters;
// Need to clone the filters to not add additional filters on every
// search term being processed.
let searchFilters = this.inputFilters.clone();
if (searchTerm) {
if (searchTerm && searchTerm.length) {
searchFilters.add('name', '~', [searchTerm]);
}

Loading…
Cancel
Save