- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/location/location.component.ts
r59329aa re29cc2e 1 import { Component, Input, OnInit, Output } from '@angular/core';1 import { Component, OnInit } from '@angular/core'; 2 2 import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 import { MatDialog } from '@angular/material/dialog';4 3 import { ActivatedRoute, Router } from '@angular/router'; 4 import { MessageService, PrimeNGConfig } from 'primeng/api'; 5 import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; 6 import { Planner } from '../_models/planner'; 5 7 import { LocationService } from '../_services/location.service'; 6 8 import { AddLocationToPlannerPanelComponent } from './add-location-to-planner-panel/add-location-to-planner-panel.component'; 9 import { Location } from '../_models/location'; 10 import { PlannerLocationDto } from '../_models/dto/plannerLocationDto'; 11 7 12 8 13 @Component({ 9 14 selector: 'app-location', 10 15 templateUrl: './location.component.html', 11 styleUrls: ['./location.component.css'] 16 styleUrls: ['./location.component.css'], 17 providers: [DialogService, MessageService] 12 18 }) 13 19 export class LocationComponent implements OnInit { 14 20 15 form: FormGroup;16 21 categoryIds: string; 17 22 cityId: number; … … 23 28 regionId: number; 24 29 locationId: number; 30 plannerLocationDto: PlannerLocationDto; 31 ref: DynamicDialogRef; 25 32 26 constructor(private fb: FormBuilder, private route: ActivatedRoute, private locationService: LocationService, 27 private router: Router, private dialog: MatDialog) { 28 this.form = fb.group({ 29 title: fb.control('initial value', Validators.required) 30 }); 33 34 35 constructor(private route: ActivatedRoute, private locationService: LocationService, 36 private router: Router, private dialogService: DialogService, private messageService: MessageService) { 31 37 this.cityId = 1; 32 38 this.companionId = 1; … … 36 42 this.regionId = 1; 37 43 this.locationId = 1; 44 this.ref = new DynamicDialogRef; 45 this.plannerLocationDto = new PlannerLocationDto(); 46 38 47 } 39 48 … … 71 80 } 72 81 73 openDialogSave(locationId){ 74 // console.log(locationId); 75 const dialogRef = this.dialog.open(AddLocationToPlannerPanelComponent, { 76 width: '250px', 77 data: {} 78 }); 79 this.router.navigate(['locations'], {queryParams: {regionId: this.regionId, companionId: this.companionId, lengthOfStay: this.lengthOfStay, categoryIds: this.categoryIds, locationId: locationId}}); 80 82 onClickSeeDetails(id: number) { 83 this.router.navigate(['location'], { queryParams: { id: id } }); 81 84 } 82 85 83 onClickSeeDetails(id: number){ 84 this.router.navigate(['location'], {queryParams: {id: id}}); 86 show(location: Location) { 87 this.ref = this.dialogService.open(AddLocationToPlannerPanelComponent, { 88 header: 'Choose a Planner', 89 width: '70%', 90 contentStyle: { "max-height": "500px", "overflow": "auto" }, 91 baseZIndex: 10000 92 }); 93 94 this.ref.onClose.subscribe((planner: Planner) => { 95 96 this.plannerLocationDto.locationId = location.id; 97 this.plannerLocationDto.plannerId = planner.id; 98 console.log("LOC ID: " + this.plannerLocationDto.locationId); 99 console.log("PLANNER ID: " + this.plannerLocationDto.plannerId); 100 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe( 101 data => { 102 console.log(data); 103 } 104 ); 105 if (planner) { 106 this.messageService.add({ severity: 'success', summary: 'Location ' + location.name + ' has been added to planner: ' , detail: planner.name }); 107 } 108 }); 109 } 110 111 ngOnDestroy() { 112 if (this.ref) { 113 this.ref.close(); 114 } 115 } 116 117 onClickBackToMyPlanners(){ 118 this.router.navigate(['planners']); 85 119 } 86 120 }
Note:
See TracChangeset
for help on using the changeset viewer.