mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 19:43:04 +00:00
[CSTPER-66] moved refreshCache function to common ComColDataService, tests have been moved accordingly.
Used HalEndpointService to discover communities search top endpoint
This commit is contained in:
@@ -101,7 +101,7 @@ export class CreateComColPageComponent<TDomain extends DSpaceObject> implements
|
||||
} else {
|
||||
this.navigateToNewPage();
|
||||
}
|
||||
this.refreshCache(dsoRD);
|
||||
this.dsoDataService.refreshCache(dsoRD);
|
||||
}
|
||||
this.notificationsService.success(null, this.translate.get(this.type.value + '.create.notifications.success'));
|
||||
});
|
||||
@@ -115,23 +115,4 @@ export class CreateComColPageComponent<TDomain extends DSpaceObject> implements
|
||||
this.router.navigate([this.frontendURL + this.newUUID]);
|
||||
}
|
||||
}
|
||||
|
||||
private refreshCache(dso: TDomain) {
|
||||
const parentCommunityUrl = this.parentCommunityUrl(dso as any);
|
||||
if (!hasValue(parentCommunityUrl)) {
|
||||
return;
|
||||
}
|
||||
this.dsoDataService.findByHref(parentCommunityUrl).pipe(
|
||||
getSucceededOrNoContentResponse(),
|
||||
take(1),
|
||||
).subscribe((rd: RemoteData<TDomain>) => {
|
||||
const href = rd.hasSucceeded && !isEmpty(rd.payload.id) ? rd.payload.id : 'communities/search/top';
|
||||
this.requestService.removeByHrefSubstring(href)
|
||||
});
|
||||
}
|
||||
|
||||
private parentCommunityUrl(dso: Collection | Community) {
|
||||
const parentCommunity = dso._links.parentCommunity;
|
||||
return isNotEmpty(parentCommunity) ? parentCommunity.href : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user