[6a3a178] | 1 | import { Component, OnInit } from '@angular/core';
|
---|
| 2 | import { Planner } from '../_models/planner';
|
---|
| 3 | import { PlannerService } from '../_services/planner.service';
|
---|
[fa375fe] | 4 | import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
|
---|
[6a80231] | 5 | import { Router } from '@angular/router';
|
---|
[6c1585f] | 6 | import { PlannerDto } from '../_models/dto/plannerDto';
|
---|
| 7 | import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
---|
[e29cc2e] | 8 | import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
|
---|
| 9 | import { PrimeNGConfig } from 'primeng/api';
|
---|
[fa375fe] | 10 |
|
---|
[6a3a178] | 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[];
|
---|
[6c1585f] | 20 | plannerDto: PlannerDto;
|
---|
| 21 | editForm: FormGroup;
|
---|
[e29cc2e] | 22 | ref: DynamicDialogRef;
|
---|
[6a80231] | 23 |
|
---|
[6c1585f] | 24 |
|
---|
[e29cc2e] | 25 | constructor(private plannerService: PlannerService, private router: Router,
|
---|
| 26 | private fb: FormBuilder, private dialogService: DialogService, private primengConfig: PrimeNGConfig) {
|
---|
[6a3a178] | 27 | this.planners = [];
|
---|
[6c1585f] | 28 | this.plannerDto = new PlannerDto();
|
---|
| 29 | this.editForm = fb.group({
|
---|
| 30 | title: fb.control('initial value', Validators.required)
|
---|
[fa375fe] | 31 | });
|
---|
[e29cc2e] | 32 | this.ref = new DynamicDialogRef;
|
---|
[6a3a178] | 33 | }
|
---|
[e29cc2e] | 34 |
|
---|
[6a3a178] | 35 | ngOnInit(): void {
|
---|
[e29cc2e] | 36 |
|
---|
| 37 | this.primengConfig.ripple = true;
|
---|
| 38 |
|
---|
[6a3a178] | 39 | this.plannerService.getAllPlanners().subscribe(
|
---|
| 40 | data => {
|
---|
| 41 | this.planners = data;
|
---|
| 42 | }
|
---|
| 43 | );
|
---|
| 44 | }
|
---|
[e29cc2e] | 45 |
|
---|
| 46 | onClickEditPlannerGet(id: number) {
|
---|
[6a80231] | 47 | console.log(id);
|
---|
[e29cc2e] | 48 | this.plannerService.getPlannerById(id).subscribe(
|
---|
| 49 | data => {
|
---|
| 50 | this.router.navigate(['edit/planner/', id]);
|
---|
| 51 | }
|
---|
| 52 | );
|
---|
[6c1585f] | 53 |
|
---|
[e29cc2e] | 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 | }
|
---|
[6a3a178] | 63 | }
|
---|