diff --git a/src/app/associate-item/associate-item-page.component.ts b/src/app/associate-item/associate-item-page.component.ts index a4bf1303294..51ffd0e01ba 100644 --- a/src/app/associate-item/associate-item-page.component.ts +++ b/src/app/associate-item/associate-item-page.component.ts @@ -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(); } @@ -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(); } @@ -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' }); } diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index 26c9d68e0ab..3234d7c5b26 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -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); + } + }