Skip to content

Commit 90a1ca6

Browse files
7.x - Clear url parameters for entity search tabs (#2735)
* 110878: Entity search - clear params on tab switch * 110878: Properly clear browse-by values when navigating * 132230: Related entity tab switching: only keep query & scope, reset page to 1 --------- Co-authored-by: Nona Luypaert <[email protected]>
1 parent 6071065 commit 90a1ca6

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
192192

193193
if (typeof params.startsWith === 'string'){
194194
this.startsWith = params.startsWith.trim();
195+
} else {
196+
this.startsWith = '';
195197
}
196198

197199
if (isNotEmpty(this.value)) {

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
3535
{
3636
provide: ActivatedRoute,
3737
useValue: {
38-
queryParams: observableOf({ tab: mockRelationType })
38+
queryParams: observableOf({ tab: mockRelationType }),
39+
snapshot: {
40+
queryParams: {
41+
scope: 'collection-uuid',
42+
query: 'test',
43+
},
44+
},
3945
},
4046
},
4147
{ provide: Router, useValue: router }
@@ -72,9 +78,11 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
7278
expect(router.navigate).toHaveBeenCalledWith([], {
7379
relativeTo: (comp as any).route,
7480
queryParams: {
75-
tab: event.nextId
81+
tab: event.nextId,
82+
query: 'test',
83+
scope: 'collection-uuid',
84+
'spc.page': 1,
7685
},
77-
queryParamsHandling: 'merge'
7886
});
7987
});
8088
});

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
6767
this.router.navigate([], {
6868
relativeTo: this.route,
6969
queryParams: {
70-
tab: event.nextId
70+
tab: event.nextId,
71+
query: this.route.snapshot.queryParams.query,
72+
scope: this.route.snapshot.queryParams.scope,
73+
'spc.page': 1,
7174
},
72-
queryParamsHandling: 'merge'
7375
});
7476
}
7577

src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="d-flex flex-row">
2-
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType == linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="[]" [queryParams]="queryParams$ | async" [queryParamsHandling]="'merge'" class="lead" role="link" tabindex="0">
2+
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType == linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="[]" [queryParams]="queryParams$ | async" class="lead" role="link" tabindex="0">
33
{{object.value}}
44
</a>
55
<span *ngIf="linkType == linkTypes.None" class="lead">

src/app/shared/starts-with/date/starts-with-date.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('StartsWithDateComponent', () => {
9898
});
9999

100100
it('should add a startsWith query parameter', () => {
101-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
101+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue}, undefined, { queryParamsHandling: '' });
102102
});
103103

104104
it('should automatically fill in the input field', () => {
@@ -120,7 +120,7 @@ describe('StartsWithDateComponent', () => {
120120
});
121121

122122
it('should add a startsWith query parameter', () => {
123-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
123+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue}, undefined, { queryParamsHandling: '' });
124124
});
125125

126126
it('should automatically fill in the input field', () => {
@@ -144,7 +144,7 @@ describe('StartsWithDateComponent', () => {
144144
});
145145

146146
it('should add a startsWith query parameter', () => {
147-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
147+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue}, undefined, { queryParamsHandling: '' });
148148
});
149149

150150
it('should automatically fill in the input field', () => {
@@ -173,7 +173,7 @@ describe('StartsWithDateComponent', () => {
173173
});
174174

175175
it('should add a startsWith query parameter', () => {
176-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
176+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue}, undefined, { queryParamsHandling: '' });
177177
});
178178
});
179179

src/app/shared/starts-with/starts-with-abstract.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
8080
this.startsWith = undefined;
8181
}
8282
if (resetPage) {
83-
this.paginationService.updateRoute(this.paginationId, {page: 1}, { startsWith: this.startsWith });
83+
this.paginationService.updateRoute(this.paginationId, {page: 1}, { startsWith: this.startsWith }, undefined, { queryParamsHandling: '' });
8484
} else {
8585
this.router.navigate([], {
8686
queryParams: Object.assign({ startsWith: this.startsWith }),
87-
queryParamsHandling: 'merge'
8887
});
8988
}
9089
}

src/app/shared/starts-with/text/starts-with-text.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('StartsWithTextComponent', () => {
6262
expect(comp.startsWith).toEqual(expectedValue);
6363
});
6464

65-
it('should add a startsWith query parameter', () => {
66-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
65+
it('should add a startsWith query parameter and clear all others', () => {
66+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue}, undefined, { queryParamsHandling: '' });
6767
});
6868
});
6969

0 commit comments

Comments
 (0)