41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Component, Inject, OnInit } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
import { BaseComponent } from '../../../../core/common/base/base.component';
|
|
import { ExternalResearcherService } from '../../../../core/services/external-sources/researcher/external-researcher.service';
|
|
import { ResearcherEditorModel } from './add-researcher.model';
|
|
import { ResearcherModel } from '../../../../core/model/researcher/researcher';
|
|
|
|
@Component({
|
|
selector: 'app-add-researcher-component',
|
|
templateUrl: 'add-researcher.component.html',
|
|
})
|
|
export class AddResearcherComponent extends BaseComponent implements OnInit {
|
|
|
|
public formGroup: FormGroup;
|
|
|
|
constructor(
|
|
private externalResearcherService: ExternalResearcherService,
|
|
public dialogRef: MatDialogRef<AddResearcherComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
) { super(); }
|
|
|
|
ngOnInit(): void {
|
|
const researcher = new ResearcherEditorModel();
|
|
this.formGroup = researcher.buildForm();
|
|
}
|
|
|
|
send(value: any) {
|
|
this.externalResearcherService.createResearcher(this.formGroup.value)
|
|
.pipe(takeUntil(this._destroyed))
|
|
.subscribe(
|
|
null, null, () => this.dialogRef.close()
|
|
);
|
|
}
|
|
|
|
addResearcher() {
|
|
this.dialogRef.close(this.formGroup.value);
|
|
}
|
|
}
|