Changeset 6c1585f for trip-planner-front/src/app/locations-form
- Timestamp:
- 11/04/21 23:10:39 (3 years ago)
- Branches:
- master
- Children:
- ceaed42
- Parents:
- 6a80231
- Location:
- trip-planner-front/src/app/locations-form
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/locations-form/locations-form.component.html
r6a80231 r6c1585f 13 13 <br> 14 14 <br> 15 <!--16 <mat-form-field class="example-full-width" appearance="fill">17 <mat-label>Please select a place</mat-label>18 <input type="text"19 placeholder="Pick one"20 aria-label="Place"21 matInput22 [formControl]="myControl"23 [matAutocomplete]="auto">24 <mat-autocomplete autoActiveFirstOption #auto="matAutocomplete">25 <mat-option *ngFor="let option of filteredOptions | async" [value]="option.name">26 {{option.name}}27 </mat-option>28 </mat-autocomplete>29 </mat-form-field>30 -->31 32 15 33 16 <div *ngIf="cityOption"> … … 40 23 </mat-form-field> 41 24 </div> 42 43 25 44 26 <div *ngIf="regionOption"> -
trip-planner-front/src/app/locations-form/locations-form.component.ts
r6a80231 r6c1585f 16 16 import { Region } from '../_models/region'; 17 17 import { RegionService } from '../_services/region.service'; 18 import { Router } from '@angular/router'; 18 19 19 20 @Component({ … … 47 48 constructor(private cityService : CityService, private regionService: RegionService, 48 49 private companionService : CompanionService, private categoryService : CategoryService, 49 private locationService: LocationService ){50 private locationService: LocationService, private router : Router){ 50 51 this.filteredOptions = new Observable<City[]>(); 51 52 this.cities = []; … … 99 100 100 101 filter(val: string): Observable<City[]> { 101 // call the service which makes the http-request102 // call the service which makes the http-request 102 103 return this.cityService.getAllCities() 103 .pipe(104 map(response => response.filter(option => {105 return option.name.toLowerCase().indexOf(val.toLowerCase()) === 0106 }))107 )108 109 }104 .pipe( 105 map(response => response.filter(option => { 106 return option.name.toLowerCase().indexOf(val.toLowerCase()) === 0 107 })) 108 ) 109 110 } 110 111 111 112 toggleSelection(chip: MatChip, category: Category){ 112 113 chip.toggleSelected(); 113 114 114 if(this.chipsSeletion.length > 0){115 if(this.chipsSeletion.indexOf(category.id) <= -1){116 this.chipsSeletion.push(category.id);117 }else{118 const index = this.chipsSeletion.indexOf(category.id);119 this.chipsSeletion.splice(index, 1);120 }121 }else{122 this.chipsSeletion.push(category.id);123 }124 console.log(this.chipsSeletion);115 if (this.chipsSeletion.length > 0) { 116 if (this.chipsSeletion.indexOf(category.id) <= -1) { 117 this.chipsSeletion.push(category.id); 118 } else { 119 const index = this.chipsSeletion.indexOf(category.id); 120 this.chipsSeletion.splice(index, 1); 121 } 122 } else { 123 this.chipsSeletion.push(category.id); 124 } 125 console.log(this.chipsSeletion); 125 126 } 126 127 127 128 128 createMyPlanner(){ 129 this.categoryIds = this.chipsSeletion.join(','); 130 console.log(this.categoryIds); 131 132 if(this.cityOption){ 133 this.locationService.getLocationsFromCity(this.cityId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 134 result => { 135 console.log(result); 136 } 137 ); 138 }else if(this.regionOption){ 139 140 this.locationService.getLocationsFromRegion(this.regionId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 141 result => { 142 console.log(result); 143 } 144 ); 145 } 146 } 147 148 chooseCityOption(){ 149 this.cityOption = true; 150 this.regionOption = false; 151 } 129 createMyPlanner() { 130 this.categoryIds = this.chipsSeletion.join(','); 131 console.log(this.categoryIds); 132 133 if (this.cityOption) { 134 this.locationService.getLocationsFromCity(this.cityId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 135 result => { 136 console.log(result); 137 this.router.navigate(['locations']); 138 } 139 ); 140 } else if (this.regionOption) { 141 this.locationService.getLocationsFromRegion(this.regionId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 142 result => { 143 console.log(result); 144 this.router.navigate(['locations']); 145 } 146 ); 147 } 148 149 150 151 } 152 153 chooseCityOption() { 154 this.cityOption = true; 155 this.regionOption = false; 156 } 152 157 chooseRegionOption() { 153 158 this.regionOption = true; … … 155 160 } 156 161 157 constraintMaxNumberDays() {158 if(this.value > this.max){159 160 162 constraintMaxNumberDays() { 163 if (this.value > this.max) { 164 this.value = this.max; 165 } 161 166 } 162 167
Note:
See TracChangeset
for help on using the changeset viewer.