mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 22:43:03 +00:00
refactoring comcol forms
This commit is contained in:

committed by
Thuur Van de Velde

parent
d37a2e051d
commit
a35dffbe95
@@ -1,54 +1,21 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { Community } from '../../core/shared/community.model';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { isNotEmpty, isNotUndefined } from '../../shared/empty.util';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { getSucceededRemoteData } from '../../core/shared/operators';
|
||||
import { CreateComColPageComponent } from '../../comcol-forms/create-comcol-page/create-comcol-page.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-create-community',
|
||||
styleUrls: ['./create-community-page.component.scss'],
|
||||
templateUrl: './create-community-page.component.html'
|
||||
})
|
||||
export class CreateCommunityPageComponent implements OnInit {
|
||||
|
||||
public parentUUID$: Observable<string>;
|
||||
public parentRD$: Observable<RemoteData<Community>>;
|
||||
|
||||
export class CreateCommunityPageComponent extends CreateComColPageComponent<Community> {
|
||||
public constructor(
|
||||
private communityDataService: CommunityDataService,
|
||||
private routeService: RouteService,
|
||||
private router: Router
|
||||
protected communityDataService: CommunityDataService,
|
||||
protected routeService: RouteService,
|
||||
protected router: Router
|
||||
) {
|
||||
|
||||
super(communityDataService, communityDataService, routeService, router);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.parentUUID$ = this.routeService.getQueryParameterValue('parent');
|
||||
this.parentUUID$.subscribe((parentID: string) => {
|
||||
if (isNotEmpty(parentID)) {
|
||||
this.parentRD$ = this.communityDataService.findById(parentID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit(community: Community) {
|
||||
this.parentUUID$.pipe(take(1)).subscribe((uuid: string) => {
|
||||
this.communityDataService.create(community, uuid)
|
||||
.pipe(getSucceededRemoteData())
|
||||
.subscribe((communityRD: RemoteData<Community>) => {
|
||||
if (isNotUndefined(communityRD)) {
|
||||
const newUUID = communityRD.payload.uuid;
|
||||
this.router.navigate(['/communities/' + newUUID]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user