2018-11-27 18:33:17 +01:00
|
|
|
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
2018-10-05 17:00:54 +02:00
|
|
|
import { FormGroup } from '@angular/forms';
|
|
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
2018-11-27 18:33:17 +01:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { BaseComponent } from '../../../core/common/base/base.component';
|
2018-10-05 17:00:54 +02:00
|
|
|
import { DataRepositoryModel } from '../../../models/dataRepositories/DataRepositoryModel';
|
2018-11-27 18:33:17 +01:00
|
|
|
import { DataRepositoryService } from '../../../services/datarepository/datarepository.service';
|
2018-09-04 11:36:18 +02:00
|
|
|
|
|
|
|
@Component({
|
2018-10-05 17:00:54 +02:00
|
|
|
selector: 'app-datarepository-referenced-model-helper',
|
|
|
|
templateUrl: 'datarepository-referenced-model-helper.component.html',
|
|
|
|
styleUrls: ['./datarepository-referenced-model-helper.component.scss'],
|
|
|
|
encapsulation: ViewEncapsulation.None
|
2018-09-04 11:36:18 +02:00
|
|
|
})
|
2018-11-27 18:33:17 +01:00
|
|
|
export class DataRepositoryReferencedModelHelperComponent extends BaseComponent implements OnInit {
|
2018-10-05 17:00:54 +02:00
|
|
|
public formGroup: FormGroup;
|
2018-09-04 11:36:18 +02:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
constructor(
|
|
|
|
private dataRepositoryService: DataRepositoryService,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
public router: Router,
|
|
|
|
public dialogRef: MatDialogRef<DataRepositoryReferencedModelHelperComponent>,
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
2018-11-27 18:33:17 +01:00
|
|
|
) { super(); }
|
2018-09-04 11:36:18 +02:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
ngOnInit(): void {
|
|
|
|
const datarepo = new DataRepositoryModel();
|
|
|
|
this.formGroup = datarepo.buildForm();
|
|
|
|
}
|
2018-09-04 11:36:18 +02:00
|
|
|
|
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
send(value: any) {
|
2018-11-27 18:33:17 +01:00
|
|
|
this.dataRepositoryService.create(this.formGroup.value)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
(item) => this.dialogRef.close(item)
|
|
|
|
);
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-09-04 11:36:18 +02:00
|
|
|
}
|