diff --git a/src/app/portal/components/results/results.component.ts b/src/app/portal/components/results/results.component.ts index 11bc01dc4..1454608c6 100644 --- a/src/app/portal/components/results/results.component.ts +++ b/src/app/portal/components/results/results.component.ts @@ -353,17 +353,17 @@ export class ResultsComponent implements OnInit, OnDestroy, AfterViewInit { ); } - doSearch(query: any, params: any){ + doSearch(queryParams: any, targetTab: any){ // Change query target - this.settingsService.changeTarget(query.target ? query.target : null); + this.settingsService.changeTarget(queryParams.target ? queryParams.target : null); // Get search target name for visuals this.searchTargetName = this.staticDataService.targets?.find( - (t) => t.value === query.target + (t) => t.value === queryParams.target )?.['viewValue' + this.currentLocale]; - this.searchService.pageSize = parseInt(query.size, 10) || 10; + this.searchService.pageSize = parseInt(queryParams.size, 10) || 10; - this.page = +query.page || 1; + this.page = +queryParams.page || 1; if (this.page > 1000) { this.pageFallback = true; this.getTabValues(); @@ -372,12 +372,12 @@ export class ResultsComponent implements OnInit, OnDestroy, AfterViewInit { // Check for Angular Univeral SSR, get filters if browser if (isPlatformBrowser(this.platformId)) { - this.filters = this.filterService.filterList(query); + this.filters = this.filterService.filterList(queryParams); } - const tabChanged = this.tab !== params.tab; + const tabChanged = this.tab !== targetTab.tab; - this.searchTerm = params.input || ''; + this.searchTerm = targetTab.input || ''; // Send search term to sort service this.sortService.getTerm(this.searchTerm); @@ -391,11 +391,11 @@ export class ResultsComponent implements OnInit, OnDestroy, AfterViewInit { this.total = 1; this.selectedTabData = this.tabData.filter( - (tab) => tab.link === params.tab + (tab) => tab.link === targetTab.tab )[0]; this.metaTags = this.metaTagsList.filter( - (tab) => tab.link === params.tab + (tab) => tab.link === targetTab.tab )[0]; // Default to publications if invalid tab @@ -405,6 +405,8 @@ export class ResultsComponent implements OnInit, OnDestroy, AfterViewInit { } this.tab = this.selectedTabData.link; + this.tabChangeService.tabQueryParams[this.tab] = queryParams; + if (tabChanged) { this.tabChangeService.changeTab(this.selectedTabData); @@ -433,12 +435,12 @@ export class ResultsComponent implements OnInit, OnDestroy, AfterViewInit { this.visual = this.visual && !!this.visualisationCategories.length; } - this.sortService.updateSort(query.sort); + this.sortService.updateSort(queryParams.sort); this.searchService.updatePageNumber( this.page, this.searchService.pageSize ); - this.searchService.updateQueryParams(query); + this.searchService.updateQueryParams(queryParams); // Check for Angular Univeral SSR, update filters if browser if (isPlatformBrowser(this.platformId)) {