Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix filter query parameter passing #1871

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/app/portal/components/results/results.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
Loading