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