mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Clear url parameters for entity search tabs (#2734)
* 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 <nona.luypaert@atmire.com>
This commit is contained in:
@@ -248,6 +248,8 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
if (typeof params.startsWith === 'string') {
|
||||
this.startsWith = params.startsWith.trim();
|
||||
} else {
|
||||
this.startsWith = '';
|
||||
}
|
||||
|
||||
if (isNotEmpty(this.value)) {
|
||||
|
@@ -44,6 +44,12 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
|
||||
provide: ActivatedRoute,
|
||||
useValue: {
|
||||
queryParams: of({ tab: mockRelationType }),
|
||||
snapshot: {
|
||||
queryParams: {
|
||||
scope: 'collection-uuid',
|
||||
query: 'test',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ provide: Router, useValue: router },
|
||||
@@ -89,8 +95,10 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
|
||||
relativeTo: (comp as any).route,
|
||||
queryParams: {
|
||||
tab: event.nextId,
|
||||
query: 'test',
|
||||
scope: 'collection-uuid',
|
||||
'spc.page': 1,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -89,8 +89,10 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
tab: event.nextId,
|
||||
query: this.route.snapshot.queryParams.query,
|
||||
scope: this.route.snapshot.queryParams.scope,
|
||||
'spc.page': 1,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<div class="d-flex flex-row">
|
||||
@if (linkType !== linkTypes.None) {
|
||||
<a [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">
|
||||
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="[]" [queryParams]="queryParams$ | async" class="lead" role="link" tabindex="0">
|
||||
{{object.value}}
|
||||
</a>
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ describe('StartsWithDateComponent', () => {
|
||||
});
|
||||
|
||||
it('should add a startsWith query parameter', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
|
||||
});
|
||||
|
||||
it('should automatically fill in the input field', () => {
|
||||
@@ -122,7 +122,7 @@ describe('StartsWithDateComponent', () => {
|
||||
});
|
||||
|
||||
it('should add a startsWith query parameter', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
|
||||
});
|
||||
|
||||
it('should automatically fill in the input field', () => {
|
||||
@@ -146,7 +146,7 @@ describe('StartsWithDateComponent', () => {
|
||||
});
|
||||
|
||||
it('should add a startsWith query parameter', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
|
||||
});
|
||||
|
||||
it('should automatically fill in the input field', () => {
|
||||
@@ -171,7 +171,7 @@ describe('StartsWithDateComponent', () => {
|
||||
});
|
||||
|
||||
it('should add a startsWith query parameter', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -92,11 +92,10 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
||||
this.startsWith = undefined;
|
||||
}
|
||||
if (resetPage) {
|
||||
this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith });
|
||||
this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith }, undefined, { queryParamsHandling: '' });
|
||||
} else {
|
||||
void this.router.navigate([], {
|
||||
queryParams: Object.assign({ startsWith: this.startsWith }),
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -74,8 +74,8 @@ describe('StartsWithTextComponent', () => {
|
||||
expect(comp.startsWith).toEqual(expectedValue);
|
||||
});
|
||||
|
||||
it('should add a startsWith query parameter', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
|
||||
it('should add a startsWith query parameter and clear all others', () => {
|
||||
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user