mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 23:43:01 +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:
@@ -15,6 +15,7 @@ import {
|
||||
} from '../../../core/shared/operators';
|
||||
import {Community} from '../../../core/shared/community.model';
|
||||
import {Collection} from '../../../core/shared/collection.model';
|
||||
import {ComColDataService} from '../../../core/data/comcol-data.service';
|
||||
|
||||
/**
|
||||
* Component representing the delete page for communities and collections
|
||||
@@ -34,7 +35,7 @@ export class DeleteComColPageComponent<TDomain extends DSpaceObject> implements
|
||||
public dsoRD$: Observable<RemoteData<TDomain>>;
|
||||
|
||||
public constructor(
|
||||
protected dsoDataService: DataService<TDomain>,
|
||||
protected dsoDataService: ComColDataService<TDomain>,
|
||||
protected router: Router,
|
||||
protected route: ActivatedRoute,
|
||||
protected notifications: NotificationsService,
|
||||
@@ -58,7 +59,7 @@ export class DeleteComColPageComponent<TDomain extends DSpaceObject> implements
|
||||
if (response.isSuccessful) {
|
||||
const successMessage = this.translate.instant((dso as any).type + '.delete.notification.success');
|
||||
this.notifications.success(successMessage)
|
||||
this.refreshCache(dso);
|
||||
this.dsoDataService.refreshCache(dso);
|
||||
} else {
|
||||
const errorMessage = this.translate.instant((dso as any).type + '.delete.notification.fail');
|
||||
this.notifications.error(errorMessage)
|
||||
@@ -74,23 +75,4 @@ export class DeleteComColPageComponent<TDomain extends DSpaceObject> implements
|
||||
onCancel(dso: TDomain) {
|
||||
this.router.navigate([this.frontendURL + '/' + dso.uuid + '/edit']);
|
||||
}
|
||||
|
||||
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): string {
|
||||
const parentCommunity = dso._links.parentCommunity;
|
||||
return isNotEmpty(parentCommunity) ? parentCommunity.href : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user