mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
111731: Remove empty arrays from query Params, since they can cause the labels to temporarily display undefined for a few milliseconds
This commit is contained in:
@@ -201,6 +201,18 @@ describe('RouteService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should remove the parameter completely if only one value is defined in an array', (done: DoneFn) => {
|
||||
route.testParams['f.author'] = ['1282121b-5394-4689-ab93-78d537764052,authority'];
|
||||
service.getParamsExceptValue('f.author', '1282121b-5394-4689-ab93-78d537764052,authority').pipe(take(1)).subscribe((params: Params) => {
|
||||
expect(params).toEqual({
|
||||
'query': '',
|
||||
'spc.page': '1',
|
||||
'f.has_content_in_original_bundle': 'true,equals',
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return all params except the applied filter even when multiple filters of the same type are selected', (done: DoneFn) => {
|
||||
route.testParams['f.author'] = ['1282121b-5394-4689-ab93-78d537764052,authority', '71b91a28-c280-4352-a199-bd7fc3312501,authority'];
|
||||
service.getParamsExceptValue('f.author', '1282121b-5394-4689-ab93-78d537764052,authority').pipe(take(1)).subscribe((params: Params) => {
|
||||
|
@@ -242,6 +242,9 @@ export class RouteService {
|
||||
delete newParams[name];
|
||||
} else if (Array.isArray(queryParamValues) && queryParamValues.includes(value)) {
|
||||
newParams[name] = (queryParamValues as string[]).filter((paramValue: string) => paramValue !== value);
|
||||
if (newParams[name].length === 0) {
|
||||
delete newParams[name];
|
||||
}
|
||||
}
|
||||
return newParams;
|
||||
}),
|
||||
|
Reference in New Issue
Block a user