Commits
lotte authored 84bdfb8306a
17 17 | import { RemoteData } from '../remote-data'; |
18 18 | import { GetRequest } from '../request.models'; |
19 19 | import { RequestService } from '../request.service'; |
20 20 | import { CacheableObject } from '../../cache/cacheable-object.model'; |
21 21 | import { FindListOptions } from '../find-list-options.model'; |
22 22 | import { PaginatedList } from '../paginated-list.model'; |
23 23 | import { ObjectCacheEntry } from '../../cache/object-cache.reducer'; |
24 24 | import { ObjectCacheService } from '../../cache/object-cache.service'; |
25 25 | import { HALDataService } from './hal-data-service.interface'; |
26 26 | |
27 + | export const EMBED_SEPARATOR = '%2F'; |
27 28 | /** |
28 29 | * Common functionality for data services. |
29 30 | * Specific functionality that not all services would need |
30 31 | * is implemented in "DataService feature" classes (e.g. {@link CreateData} |
31 32 | * |
32 33 | * All DataService (or DataService feature) classes must |
33 34 | * - extend this class (or {@link IdentifiableDataService}) |
34 35 | * - implement any DataService features it requires in order to forward calls to it |
35 36 | * |
36 37 | * ``` |
194 195 | * Add the nested followLinks to the embed param, separated by a /, and their sizes, recursively |
195 196 | * @param embedString embedString so far (recursive) |
196 197 | * @param href The href the params are to be added to |
197 198 | * @param args params for the query string |
198 199 | * @param linksToFollow links we want to embed in query string if shouldEmbed is true |
199 200 | */ |
200 201 | protected addNestedEmbeds(embedString: string, href: string, args: string[], linksToFollow: FollowLinkConfig<T>[]): string[] { |
201 202 | let nestEmbed = embedString; |
202 203 | linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => { |
203 204 | if (hasValue(linkToFollow) && linkToFollow.shouldEmbed) { |
204 - | nestEmbed = nestEmbed + '/' + String(linkToFollow.name); |
205 + | nestEmbed = nestEmbed + EMBED_SEPARATOR + String(linkToFollow.name); |
205 206 | // Add the nested embeds size if given in the FollowLinkConfig.FindListOptions |
206 207 | if (hasValue(linkToFollow.findListOptions) && hasValue(linkToFollow.findListOptions.elementsPerPage)) { |
207 208 | const nestedEmbedSize = 'embed.size=' + nestEmbed.split('=')[1] + '=' + linkToFollow.findListOptions.elementsPerPage; |
208 209 | args = this.addHrefArg(href, args, nestedEmbedSize); |
209 210 | } |
210 211 | if (hasValue(linkToFollow.linksToFollow) && isNotEmpty(linkToFollow.linksToFollow)) { |
211 212 | args = this.addNestedEmbeds(nestEmbed, href, args, linkToFollow.linksToFollow); |
212 213 | } else { |
213 214 | args = this.addHrefArg(href, args, nestEmbed); |
214 215 | } |