2019-01-18 18:03:45 +01:00
|
|
|
import { Component, Inject, OnInit } from '@angular/core';
|
|
|
|
import { FormGroup } from '@angular/forms';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
2019-01-18 18:03:45 +01:00
|
|
|
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';
|
2019-07-31 12:07:32 +02:00
|
|
|
import { ResearcherModel } from '../../../../core/model/researcher/researcher';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
|
|
|
@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(
|
2019-07-31 12:07:32 +02:00
|
|
|
null, null, () => this.dialogRef.close()
|
2019-01-18 18:03:45 +01:00
|
|
|
);
|
|
|
|
}
|
2019-07-31 12:07:32 +02:00
|
|
|
|
|
|
|
addResearcher() {
|
|
|
|
this.dialogRef.close(this.formGroup.value);
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|