1 | import { Component, OnInit } from '@angular/core';
|
---|
2 | import { Planner } from '../_models/planner';
|
---|
3 | import { PlannerService } from '../_services/planner.service';
|
---|
4 | import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
---|
5 | import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
|
---|
6 | import { Router } from '@angular/router';
|
---|
7 | import { PlannerDto } from '../_models/dto/plannerDto';
|
---|
8 | import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
---|
9 |
|
---|
10 |
|
---|
11 | @Component({
|
---|
12 | selector: 'app-planner',
|
---|
13 | templateUrl: './planner.component.html',
|
---|
14 | styleUrls: ['./planner.component.css']
|
---|
15 | })
|
---|
16 | export class PlannerComponent implements OnInit {
|
---|
17 |
|
---|
18 | planners: Planner[];
|
---|
19 | plannerDto: PlannerDto;
|
---|
20 | editForm: FormGroup;
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | constructor(private plannerService: PlannerService, private dialog: MatDialog, private router: Router,
|
---|
25 | private fb : FormBuilder) {
|
---|
26 | this.planners = [];
|
---|
27 | this.plannerDto = new PlannerDto();
|
---|
28 | this.editForm = fb.group({
|
---|
29 | title: fb.control('initial value', Validators.required)
|
---|
30 | });
|
---|
31 | };
|
---|
32 |
|
---|
33 | openDialog(): void {
|
---|
34 | const dialogRef = this.dialog.open(CreateInitialPlannerComponent, {
|
---|
35 | width: '250px',
|
---|
36 | data: {}
|
---|
37 | });
|
---|
38 | }
|
---|
39 |
|
---|
40 | ngOnInit(): void {
|
---|
41 | this.plannerService.getAllPlanners().subscribe(
|
---|
42 | data => {
|
---|
43 | this.planners = data;
|
---|
44 | }
|
---|
45 | );
|
---|
46 | }
|
---|
47 |
|
---|
48 | onClickEditPlannerGet(id: number){
|
---|
49 | console.log(id);
|
---|
50 | this.plannerService.getPlannerById(id).subscribe(
|
---|
51 | data => {
|
---|
52 | this.router.navigate(['edit/planner/', id]);
|
---|
53 | }
|
---|
54 | );
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | }
|
---|