- Timestamp:
- 11/26/21 20:07:18 (3 years ago)
- Branches:
- master
- Children:
- 1ad8e64
- Parents:
- e29cc2e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/location/location.component.ts
re29cc2e r8d391a1 1 1 import { Component, OnInit } from '@angular/core'; 2 import { FormBuilder, FormGroup, Validators } from '@angular/forms';3 2 import { ActivatedRoute, Router } from '@angular/router'; 4 import { MessageService , PrimeNGConfig} from 'primeng/api';3 import { MessageService } from 'primeng/api'; 5 4 import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; 6 5 import { Planner } from '../_models/planner'; … … 30 29 plannerLocationDto: PlannerLocationDto; 31 30 ref: DynamicDialogRef; 32 31 locationIdsPlanner: number[]; 33 32 34 33 … … 42 41 this.regionId = 1; 43 42 this.locationId = 1; 44 this.ref = new DynamicDialogRef ;43 this.ref = new DynamicDialogRef(); 45 44 this.plannerLocationDto = new PlannerLocationDto(); 46 45 this.locationIdsPlanner = []; 47 46 } 48 47 … … 85 84 86 85 show(location: Location) { 86 console.log(location.id); 87 87 this.ref = this.dialogService.open(AddLocationToPlannerPanelComponent, { 88 88 header: 'Choose a Planner', … … 93 93 94 94 this.ref.onClose.subscribe((planner: Planner) => { 95 96 95 this.plannerLocationDto.locationId = location.id; 97 96 this.plannerLocationDto.plannerId = planner.id; 98 97 console.log("LOC ID: " + this.plannerLocationDto.locationId); 99 98 console.log("PLANNER ID: " + this.plannerLocationDto.plannerId); 100 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe( 101 data => { 102 console.log(data); 99 100 this.locationService.getAllLocationIdsForPlanner(planner.id).subscribe( 101 lid => { 102 if (lid.length == 0) { 103 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe( 104 data => { 105 console.log(data); 106 } 107 ); 108 this.messageService.add({ severity: 'success', summary: 'Location ' + location.name + ' has been added to planner: ', detail: planner.name }); 109 110 } else if (lid.length > 0) { 111 if (lid.indexOf(this.plannerLocationDto.locationId) !== -1) { 112 console.log("LOKACIJATA VEKE JA IMA VO PLANEROT"); 113 this.messageService.add({ severity: 'error', summary: 'Location ' + location.name + ' already exists in the planner.' }); 114 } else { 115 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe( 116 data => { 117 console.log(data); 118 } 119 ); 120 this.messageService.add({ severity: 'success', summary: 'Location ' + location.name + ' has been added to planner: ', detail: planner.name }); 121 } 122 123 } 103 124 } 104 125 ); 105 if (planner) { 106 this.messageService.add({ severity: 'success', summary: 'Location ' + location.name + ' has been added to planner: ' , detail: planner.name }); 107 } 126 127 108 128 }); 109 129 } … … 115 135 } 116 136 117 onClickBackToMyPlanners() {137 onClickBackToMyPlanners() { 118 138 this.router.navigate(['planners']); 119 139 } 140 141 120 142 }
Note:
See TracChangeset
for help on using the changeset viewer.