source: trip-planner-front/src/app/planner/planner.component.ts@ e29cc2e

Last change on this file since e29cc2e was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import { Component, OnInit } from '@angular/core';
2import { Planner } from '../_models/planner';
3import { PlannerService } from '../_services/planner.service';
4import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
5import { Router } from '@angular/router';
6import { PlannerDto } from '../_models/dto/plannerDto';
7import { FormBuilder, FormGroup, Validators } from '@angular/forms';
8import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
9import { PrimeNGConfig } from 'primeng/api';
10
11
12@Component({
13 selector: 'app-planner',
14 templateUrl: './planner.component.html',
15 styleUrls: ['./planner.component.css']
16})
17export 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}
Note: See TracBrowser for help on using the repository browser.