argos/dmp-frontend/src/app/dataset-wizard/dataset-wizard.component.ts

70 lines
2.8 KiB
TypeScript

import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
import { FormGroup, Validators, FormBuilder } from "@angular/forms";
import { AutoCompleteConfiguration } from "../shared/components/autocomplete/AutoCompleteConfiguration";
import { DatasetWizardService } from "../services/dataset-wizard/dataset-wizard.service";
import { DataManagementPlanCriteria } from "../models/criteria/data-management-plan/DataManagementPlanCriteria";
import { DataManagementPlanModel } from "../models/data-managemnt-plans/DataManagementPlanModel";
import { JsonSerializer } from "../utilities/JsonSerializer";
import { Observable } from "rxjs/Observable";
import { RequestItem } from "../models/criteria/RequestItem";
@Component({
selector: 'app-dataset-wizard-component',
templateUrl: 'dataset-wizard.component.html',
styleUrls: ['./dataset-wizard.component.scss'],
providers: [DatasetWizardService],
encapsulation: ViewEncapsulation.None
})
export class DatasetWizardComponent implements AfterViewInit {
dmpAutoCompleteConfiguration: AutoCompleteConfiguration;
constructor(
private datasetWizardService: DatasetWizardService,
private formBuilder: FormBuilder
) {
}
isLinear = false;
firstStepFormGroup: FormGroup;
secondFormGroup: FormGroup;
ngOnInit() {
let dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
dmpRequestItem.criteria = new DataManagementPlanCriteria();
this.dmpAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.userDmps.bind(this.datasetWizardService), dmpRequestItem);
this.firstStepFormGroup = this.formBuilder.group({
dataManagementPlan: ['dataManagementPlan', Validators.required]
});
this.secondFormGroup = this.formBuilder.group({
secondCtrl: ['', Validators.required]
});
}
ngAfterViewInit() {
// this.route.params.subscribe((params: Params) => {
// const itemId = params['id'];
// if (itemId != null) {
// this.isNew = false;
// this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
// .subscribe(data => {
// this.dataManagementPlan = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(data, DataManagementPlanModel);
// this.formGroup = this.dataManagementPlan.buildForm();
// });
// } else {
// this.dataManagementPlan = new DataManagementPlanModel();
// setTimeout(() => {
// this.formGroup = this.dataManagementPlan.buildForm();
// });
// }
// });
}
public cancel(): void {
//this.router.navigate(['/dataManagementPlans']);
}
}