1 | import { Component, OnInit } from '@angular/core';
|
---|
2 | import { Planner } from '../_models/planner';
|
---|
3 | import { PlannerService } from '../_services/planner.service';
|
---|
4 | import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
|
---|
5 | import { Router } from '@angular/router';
|
---|
6 | import { PlannerDto } from '../_models/dto/plannerDto';
|
---|
7 | import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
---|
8 | import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
|
---|
9 | import { PrimeNGConfig } from 'primeng/api';
|
---|
10 |
|
---|
11 |
|
---|
12 | @Component({
|
---|
13 | selector: 'app-planner',
|
---|
14 | templateUrl: './planner.component.html',
|
---|
15 | styleUrls: ['./planner.component.css']
|
---|
16 | })
|
---|
17 | export class PlannerComponent implements OnInit {
|
---|
18 |
|
---|
19 | planners: Planner[];
|
---|
20 | plannerDto: PlannerDto;
|
---|
21 | editForm: FormGroup;
|
---|
22 | ref: DynamicDialogRef;
|
---|
23 |
|
---|
24 |
|
---|
25 | constructor(private plannerService: PlannerService, private router: Router,
|
---|
26 | private fb: FormBuilder, private dialogService: DialogService, private primengConfig: PrimeNGConfig) {
|
---|
27 | this.planners = [];
|
---|
28 | this.plannerDto = new PlannerDto();
|
---|
29 | this.editForm = fb.group({
|
---|
30 | title: fb.control('initial value', Validators.required)
|
---|
31 | });
|
---|
32 | this.ref = new DynamicDialogRef;
|
---|
33 | }
|
---|
34 |
|
---|
35 | ngOnInit(): void {
|
---|
36 |
|
---|
37 | this.primengConfig.ripple = true;
|
---|
38 |
|
---|
39 | this.plannerService.getAllPlanners().subscribe(
|
---|
40 | data => {
|
---|
41 | this.planners = data;
|
---|
42 | }
|
---|
43 | );
|
---|
44 | }
|
---|
45 |
|
---|
46 | onClickEditPlannerGet(id: number) {
|
---|
47 | console.log(id);
|
---|
48 | this.plannerService.getPlannerById(id).subscribe(
|
---|
49 | data => {
|
---|
50 | this.router.navigate(['edit/planner/', id]);
|
---|
51 | }
|
---|
52 | );
|
---|
53 |
|
---|
54 | }
|
---|
55 | show() {
|
---|
56 | this.ref = this.dialogService.open(CreateInitialPlannerComponent, {
|
---|
57 | header: 'Create initial planner',
|
---|
58 | width: '70%',
|
---|
59 | contentStyle: { "max-height": "500px", "overflow": "auto" },
|
---|
60 | baseZIndex: 10000
|
---|
61 | });
|
---|
62 | }
|
---|
63 | }
|
---|