Skip to content

Commit

Permalink
update search when pressing (not)connected button on associate-item-page
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangantner committed Apr 25, 2024
1 parent 93c8e3b commit ddd1172
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/app/associate-item/associate-item-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ export class AssociateItemPageComponent implements OnInit, OnDestroy {
q = q.replace(/^ */, '');
q = q.replace(/ *$/, '');
q = q.replace(/ +/g, ' ');
this.search.searchOptions$.next(Object.assign((this.search.searchConfigService.paginatedSearchOptions as any).value, {query: q}));
this.updateSearch((this.search.searchConfigService.paginatedSearchOptions as any).value);

this.updateSearch(q);
this.search.retrieveResults();
$event.preventDefault();
}

Expand All @@ -300,8 +301,9 @@ export class AssociateItemPageComponent implements OnInit, OnDestroy {
q = q.replace(/^ */, '');
q = q.replace(/ *$/, '');
q = q.replace(/ +/g, ' ');
this.search.searchOptions$.next(Object.assign((this.search.searchConfigService.paginatedSearchOptions as any).value, {query: q}));
this.updateSearch((this.search.searchConfigService.paginatedSearchOptions as any).value);

this.updateSearch(q);
this.search.retrieveResults();
$event.preventDefault();
}

Expand All @@ -316,20 +318,22 @@ export class AssociateItemPageComponent implements OnInit, OnDestroy {
q += ' *';
}

this.search.searchOptions$.next(Object.assign((this.search.searchConfigService.paginatedSearchOptions as any).value, {query: q}));
this.updateSearch((this.search.searchConfigService.paginatedSearchOptions as any).value);
this.updateSearch(q);
this.search.retrieveResults();
$event.preventDefault();
}

/**
* Updates the search URL
* Updates the search URL query and jump to page 1
* @param data Updated parameters
*/
updateSearch(data: any) {
const queryParams = Object.assign({}, data);

this.router.navigate(this.getSearchLinkParts(), {
queryParams: queryParams,
queryParams: {
query: data as string,
[this.search.paginationId + '.page']: 1
},
queryParamsHandling: 'merge'
});
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/shared/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,14 @@ export class SearchComponent implements OnInit, OnDestroy {
this.sidebarService.toggle();
}

/**
* Experimental to use: Retrieve the results from the current options.
* Might be called when the query has been changed in the search configuration service by some button or so and configuration or context have not changed.
*/
public retrieveResults(){
this.refreshFilters.next(true);
this.retrieveFilters(this.searchOptions$.value);
this.retrieveSearchResults(this.searchOptions$.value);
}

}

0 comments on commit ddd1172

Please sign in to comment.