[6a80231] | 1 | import { ResourceLoader } from '@angular/compiler';
|
---|
| 2 | import { Route } from '@angular/compiler/src/core';
|
---|
[fa375fe] | 3 | import { Component, Inject, OnInit } from '@angular/core';
|
---|
[6a80231] | 4 | import { NgForm } from '@angular/forms';
|
---|
[fa375fe] | 5 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
---|
[6a80231] | 6 | import { ActivatedRoute, Params, Router } from '@angular/router';
|
---|
| 7 | import { PlannerDto } from '../_models/dto/plannerDto';
|
---|
| 8 | import { Planner } from '../_models/planner';
|
---|
| 9 | import { PlannerService } from '../_services/planner.service';
|
---|
[fa375fe] | 10 |
|
---|
| 11 | @Component({
|
---|
| 12 | selector: 'app-create-initial-planner',
|
---|
| 13 | templateUrl: './create-initial-planner.component.html',
|
---|
| 14 | styleUrls: ['./create-initial-planner.component.css']
|
---|
| 15 | })
|
---|
| 16 | export class CreateInitialPlannerComponent implements OnInit {
|
---|
| 17 |
|
---|
[6a80231] | 18 | planner: Planner;
|
---|
| 19 | planners: Planner[];
|
---|
| 20 | plannerDto: PlannerDto;
|
---|
| 21 |
|
---|
[ceaed42] | 22 | constructor(private dialogRef: MatDialogRef<CreateInitialPlannerComponent>,
|
---|
[6a80231] | 23 | private plannerService : PlannerService, private router : Router) {
|
---|
| 24 | this.planner = new Planner;
|
---|
| 25 | this.planners = [];
|
---|
| 26 | this.plannerDto = new PlannerDto();
|
---|
| 27 | }
|
---|
[fa375fe] | 28 |
|
---|
| 29 | ngOnInit(): void {
|
---|
[6a80231] | 30 | this.planner = new Planner();
|
---|
| 31 | this.plannerDto = new PlannerDto();
|
---|
[fa375fe] | 32 | }
|
---|
| 33 |
|
---|
| 34 | onCancelClick(): void {
|
---|
| 35 | this.dialogRef.close();
|
---|
| 36 | }
|
---|
[6a80231] | 37 |
|
---|
| 38 | onFormSubmitPlanner(form: NgForm){
|
---|
| 39 | console.log(this.planner);
|
---|
[ceaed42] | 40 | this.plannerService.postInitialPlanner(this.planner).subscribe(
|
---|
[6a80231] | 41 | data=>{
|
---|
| 42 | console.log(data);
|
---|
| 43 | this.router.navigate(['planner']);
|
---|
| 44 | },
|
---|
| 45 | error => console.log('oops', error)
|
---|
| 46 | );
|
---|
| 47 | window.location.reload();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[fa375fe] | 50 |
|
---|
[6a80231] | 51 | } |
---|