68930: rename forwardToRest typo fix

This commit is contained in:
Marie Verdonck
2020-02-21 15:55:41 +01:00
parent dffcd745af
commit 1f71274db6
3 changed files with 14 additions and 14 deletions

View File

@@ -177,14 +177,14 @@ describe('DataService', () => {
});
});
it('should not include linksToFollow with shootEmbed = false', () => {
it('should not include linksToFollow with shouldEmbed = false', () => {
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'bundles' as any,
shootEmbed: false,
shouldEmbed: false,
});
const mockFollowLinkConfig2: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'owningCollection' as any,
shootEmbed: false,
shouldEmbed: false,
});
const mockFollowLinkConfig3: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'templateItemOf' as any,
@@ -249,14 +249,14 @@ describe('DataService', () => {
expect(result).toEqual(expected);
});
it('should not include linksToFollow with shootEmbed = false', () => {
it('should not include linksToFollow with shouldEmbed = false', () => {
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'bundles' as any,
shootEmbed: false,
shouldEmbed: false,
});
const mockFollowLinkConfig2: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'owningCollection' as any,
shootEmbed: false,
shouldEmbed: false,
});
const mockFollowLinkConfig3: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
name: 'templateItemOf' as any,

View File

@@ -155,13 +155,13 @@ export abstract class DataService<T extends CacheableObject> {
/**
* Adds the embed options to the link for the request
* @param args params for the query string
* @param linksToFollow links we want to embed in query string if shootEmbed is true
* @param linksToFollow links we want to embed in query string if shouldEmbed is true
*/
protected addEmbedParams(args: any, ...linksToFollow: Array<FollowLinkConfig<T>>) {
if (linksToFollow !== undefined) {
[...linksToFollow].forEach((linkToFollow: FollowLinkConfig<T>) => {
console.log('linksToFollow', linksToFollow)
if (linkToFollow.shootEmbed) {
if (linkToFollow.shouldEmbed) {
const embedString = 'embed=' + String(linkToFollow.name);
const embedWithNestedString = this.addNestedEmbeds(embedString, ...linkToFollow.linksToFollow);
args = [...args, embedWithNestedString];
@@ -174,14 +174,14 @@ export abstract class DataService<T extends CacheableObject> {
/**
* Add the nested followLinks to the embed param, recursively, separated by a /
* @param embedString embedString so far (recursive)
* @param linksToFollow links we want to embed in query string if shootEmbed is true
* @param linksToFollow links we want to embed in query string if shouldEmbed is true
*/
protected addNestedEmbeds(embedString: string, ...linksToFollow: Array<FollowLinkConfig<T>>): string {
let nestEmbed = embedString;
if (linksToFollow !== undefined) {
console.log('linksToFollow addNestedEmbed', linksToFollow);
[...linksToFollow].forEach((linkToFollow: FollowLinkConfig<T>) => {
if (linkToFollow.shootEmbed) {
if (linkToFollow.shouldEmbed) {
nestEmbed = nestEmbed + '/' + String(linkToFollow.name);
if (linkToFollow.linksToFollow !== undefined) {
nestEmbed = this.addNestedEmbeds(nestEmbed, ...linkToFollow.linksToFollow);

View File

@@ -27,7 +27,7 @@ export class FollowLinkConfig<R extends HALResource> {
/**
* Forward to rest which links we're following, so these can already be embedded
*/
shootEmbed? = true;
shouldEmbed? = true;
}
/**
@@ -41,19 +41,19 @@ export class FollowLinkConfig<R extends HALResource> {
* in a certain way
* @param linksToFollow: a list of {@link FollowLinkConfig}s to
* use on the retrieved object.
* @param shootEmbed: boolean to check whether to forward info on followLinks to rest,
* @param shouldEmbed: boolean to check whether to forward info on followLinks to rest,
* so these can be embedded, default true
*/
export const followLink = <R extends HALResource>(
linkName: keyof R['_links'],
findListOptions?: FindListOptions,
shootEmbed = true,
shouldEmbed = true,
...linksToFollow: Array<FollowLinkConfig<any>>
): FollowLinkConfig<R> => {
return {
name: linkName,
findListOptions,
shootEmbed: shootEmbed,
shouldEmbed: shouldEmbed,
linksToFollow
}
};