You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { Component, Inject, OnInit } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
import { BaseComponent } from '../../../core/common/base/base.component';
|
|
import { ResearcherModel } from '../../../models/researcher/ResearcherModel';
|
|
import { ResearcherService } from '../../../services/researchers/researchers.service';
|
|
|
|
@Component({
|
|
selector: 'app-add-researchers-component',
|
|
templateUrl: 'add-researchers.component.html',
|
|
|
|
})
|
|
export class AddResearchersComponent extends BaseComponent implements OnInit {
|
|
|
|
public formGroup: FormGroup;
|
|
|
|
constructor(
|
|
private researcherService: ResearcherService,
|
|
private route: ActivatedRoute,
|
|
public router: Router,
|
|
public dialogRef: MatDialogRef<AddResearchersComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
) { super(); }
|
|
|
|
ngOnInit(): void {
|
|
const researcher = new ResearcherModel();
|
|
this.formGroup = researcher.buildForm();
|
|
}
|
|
|
|
|
|
send(value: any) {
|
|
this.researcherService.createResearcher(this.formGroup.value)
|
|
.pipe(takeUntil(this._destroyed))
|
|
.subscribe(
|
|
null, null, () => this.dialogRef.close()
|
|
);
|
|
}
|
|
}
|