Skip to content
Snippets Groups Projects
Commit 6c8e4988 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

54472: Small changes

parent 6973c66d
No related branches found
No related tags found
No related merge requests found
......@@ -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<string>;
public communityRDObs: Observable<RemoteData<Community>>;
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<DSpaceObject>) => {
if (rd.hasSucceeded) {
this.router.navigateByUrl('');
}
this.collectionDataService.create(collection, uuid).subscribe((rd: RemoteData<DSpaceObject>) => {
const url: string = '/collections/' + rd.payload.id;
this.router.navigateByUrl(url);
});
});
}
......
......@@ -61,7 +61,7 @@ export class DSpaceRESTv2Service {
request(method: RestRequestMethod, url: string, body?: any, options?: HttpOptions): Observable<DSpaceRESTV2Response> {
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';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment