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
RevLine 
[6a3a178]1import { Component, OnInit } from '@angular/core';
2import { Planner } from '../_models/planner';
3import { PlannerService } from '../_services/planner.service';
[fa375fe]4import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
[6a80231]5import { Router } from '@angular/router';
[6c1585f]6import { PlannerDto } from '../_models/dto/plannerDto';
7import { FormBuilder, FormGroup, Validators } from '@angular/forms';
[e29cc2e]8import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
9import { 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})
17export 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}
Note: See TracBrowser for help on using the repository browser.