mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Added startsWith param to getFindAllHref
This commit is contained in:
@@ -104,15 +104,25 @@ describe('DataService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should include startsWith in href if startsWith provided in options', () => {
|
||||||
|
options = { startsWith: 'ab' };
|
||||||
|
const expected = `${endpoint}?startsWith=${options.startsWith}`;
|
||||||
|
|
||||||
|
(service as any).getFindAllHref(endpoint, options).subscribe((value) => {
|
||||||
|
expect(value).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should include all provided options in href', () => {
|
it('should include all provided options in href', () => {
|
||||||
const sortOptions = new SortOptions('field1', SortDirection.DESC)
|
const sortOptions = new SortOptions('field1', SortDirection.DESC)
|
||||||
options = {
|
options = {
|
||||||
currentPage: 6,
|
currentPage: 6,
|
||||||
elementsPerPage: 10,
|
elementsPerPage: 10,
|
||||||
sort: sortOptions
|
sort: sortOptions,
|
||||||
|
startsWith: 'ab'
|
||||||
}
|
}
|
||||||
const expected = `${endpoint}?page=${options.currentPage - 1}&size=${options.elementsPerPage}` +
|
const expected = `${endpoint}?page=${options.currentPage - 1}&size=${options.elementsPerPage}` +
|
||||||
`&sort=${sortOptions.field},${sortOptions.direction}`;
|
`&sort=${sortOptions.field},${sortOptions.direction}&startsWith=${options.startsWith}`;
|
||||||
|
|
||||||
(service as any).getFindAllHref(endpoint, options).subscribe((value) => {
|
(service as any).getFindAllHref(endpoint, options).subscribe((value) => {
|
||||||
expect(value).toBe(expected);
|
expect(value).toBe(expected);
|
||||||
|
@@ -45,6 +45,10 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
|||||||
args.push(`sort=${options.sort.field},${options.sort.direction}`);
|
args.push(`sort=${options.sort.field},${options.sort.direction}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasValue(options.startsWith)) {
|
||||||
|
args.push(`startsWith=${options.startsWith}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotEmpty(args)) {
|
if (isNotEmpty(args)) {
|
||||||
return result.map((href: string) => new URLCombiner(href, `?${args.join('&')}`).toString());
|
return result.map((href: string) => new URLCombiner(href, `?${args.join('&')}`).toString());
|
||||||
} else {
|
} else {
|
||||||
|
@@ -141,6 +141,7 @@ export class FindAllOptions {
|
|||||||
elementsPerPage?: number;
|
elementsPerPage?: number;
|
||||||
currentPage?: number;
|
currentPage?: number;
|
||||||
sort?: SortOptions;
|
sort?: SortOptions;
|
||||||
|
startsWith?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FindAllRequest extends GetRequest {
|
export class FindAllRequest extends GetRequest {
|
||||||
|
Reference in New Issue
Block a user