another intermediate commit

This commit is contained in:
Lotte Hofstede
2018-05-18 16:34:04 +02:00
parent ca8c1830aa
commit 2a8de6dc49
2 changed files with 9 additions and 6 deletions

View File

@@ -39,7 +39,7 @@ export class CollectionsComponent implements OnInit {
} }
hasSucceeded() { hasSucceeded() {
this.item.owner.map((rd: RemoteData<Collection>) => rd.hasSucceeded) return this.item.owner.map((rd: RemoteData<Collection>) => rd.hasSucceeded);
} }
} }

View File

@@ -34,7 +34,7 @@ export abstract class BaseResponseParsingService {
} else if (Array.isArray(data)) { } else if (Array.isArray(data)) {
return this.processArray(data, requestHref); return this.processArray(data, requestHref);
} else if (isObjectLevel(data)) { } else if (isObjectLevel(data)) {
const object = this.deserialize(data, requestHref); let object = this.deserialize(data, requestHref);
this.cache(object, requestHref); this.cache(object, requestHref);
if (isNotEmpty(data._embedded)) { if (isNotEmpty(data._embedded)) {
const list = {}; const list = {};
@@ -42,12 +42,10 @@ export abstract class BaseResponseParsingService {
.keys(data._embedded) .keys(data._embedded)
.filter((property) => data._embedded.hasOwnProperty(property)) .filter((property) => data._embedded.hasOwnProperty(property))
.forEach((property) => { .forEach((property) => {
console.log(data._embedded[property]);
const parsedObj = this.process<ObjectDomain, ObjectType>(data._embedded[property], requestHref); const parsedObj = this.process<ObjectDomain, ObjectType>(data._embedded[property], requestHref);
list[property] = parsedObj; list[property] = parsedObj;
}); });
console.log(list); object = Object.assign({}, object, list);
Object.assign(object, list);
} }
return object; return object;
} }
@@ -66,7 +64,12 @@ export abstract class BaseResponseParsingService {
protected processPaginatedList<ObjectDomain, ObjectType>(data: any, requestHref: string): PaginatedList<ObjectDomain> { protected processPaginatedList<ObjectDomain, ObjectType>(data: any, requestHref: string): PaginatedList<ObjectDomain> {
const pageInfo: PageInfo = this.processPageInfo(data); const pageInfo: PageInfo = this.processPageInfo(data);
const list = this.flattenSingleKeyObject(data._embedded); let list = data._embedded;
// Workaround for inconsistancy in rest response - sometimes page embeds are wrapped in another object
if (!Array.isArray(list)) {
list = this.flattenSingleKeyObject(list);
}
const page: ObjectDomain[] = this.processArray(list, requestHref); const page: ObjectDomain[] = this.processArray(list, requestHref);
return new PaginatedList<ObjectDomain>(pageInfo, page); return new PaginatedList<ObjectDomain>(pageInfo, page);
} }