diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.ts b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts index 6cca8f1d09..aea405ea09 100644 --- a/src/app/+collection-page/create-collection-page/create-collection-page.component.ts +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts @@ -10,7 +10,7 @@ import { Router } from '@angular/router'; import { DSOSuccessResponse, ErrorResponse } from '../../core/cache/response-cache.models'; import { Observable } from 'rxjs/Observable'; import { ResponseCacheEntry } from '../../core/cache/response-cache.reducer'; -import { map, take } from 'rxjs/operators'; +import { first, map, take } from 'rxjs/operators'; import { RemoteData } from '../../core/data/remote-data'; import { isNotEmpty } from '../../shared/empty.util'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; @@ -26,7 +26,12 @@ export class CreateCollectionPageComponent { public parentUUID$: Observable; public communityRDObs: Observable>; - public constructor(private collectionDataService: CollectionDataService, private communityDataService: CommunityDataService, private routeService: RouteService, private router: Router) { + public constructor( + private collectionDataService: CollectionDataService, + private communityDataService: CommunityDataService, + private routeService: RouteService, + private router: Router + ) { this.parentUUID$ = this.routeService.getQueryParameterValue('parent'); this.parentUUID$.subscribe((uuid: string) => { if (isNotEmpty(uuid)) { @@ -47,10 +52,9 @@ export class CreateCollectionPageComponent { // TODO: metadata for news and provenance ] }); - this.collectionDataService.create(collection, uuid).pipe(take(1)).subscribe((rd: RemoteData) => { - if (rd.hasSucceeded) { - this.router.navigateByUrl(''); - } + this.collectionDataService.create(collection, uuid).subscribe((rd: RemoteData) => { + const url: string = '/collections/' + rd.payload.id; + this.router.navigateByUrl(url); }); }); } diff --git a/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts b/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts index c8cced9e8a..eafa9c46a0 100644 --- a/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts +++ b/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts @@ -61,7 +61,7 @@ export class DSpaceRESTv2Service { request(method: RestRequestMethod, url: string, body?: any, options?: HttpOptions): Observable { const requestOptions: HttpOptions = {}; requestOptions.body = body; - if (method === RestRequestMethod.Post && isNotEmpty(body)) { + if (method === RestRequestMethod.Post && isNotEmpty(body.name)) { requestOptions.body = this.buildFormData(body); } requestOptions.observe = 'response';