Changeset 188ee53 for trip-planner-front


Ignore:
Timestamp:
10/19/21 16:40:43 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
6a80231
Parents:
eed0bf8
Message:

location-form

Location:
trip-planner-front
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/_services/location.service.ts

    reed0bf8 r188ee53  
    99    constructor(private httpClient : HttpClient){}
    1010
    11     getAllPlaces(locationId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Object[]>{
    12         let url = "http://localhost:8080/api/trip/locations";
    13         return this.httpClient.get<Location[]>(url + '?locationId=' + locationId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds);
     11    getLocationsFromCity(cityId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Object[]>{
     12        let url = "http://localhost:8080/api/city/locations";
     13        return this.httpClient.get<Location[]>(url + '?cityId=' + cityId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds);
     14    }
     15
     16    getLocationsFromRegion(regionId: number, companionId: number, lengthOfStay: number, categoryIds: string):Observable<Object[]>{
     17        let url = "http://localhost:8080/api/region/locations";
     18        return this.httpClient.get<Location[]>(url + '?regionId=' + regionId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds);
    1419    }
    1520}
  • trip-planner-front/src/app/locations-form/locations-form.component.css

    reed0bf8 r188ee53  
    1818  float: right;
    1919}
     20
     21.colorClass{
     22  color:yellow;
     23}
  • trip-planner-front/src/app/locations-form/locations-form.component.html

    reed0bf8 r188ee53  
    33<div class="example-form">
    44
    5   <div class="d-block">
     5  <div class="form-group">
    66    <button class="btn" (click)="chooseCityOption()" >
    77      City
     
    3535    <mat-form-field appearance="fill" class="example-full-width">
    3636      <mat-label>Please select a city</mat-label>
    37       <mat-select [(ngModel)]="locationId" placeholder="Select city">
     37      <mat-select [(ngModel)]="cityId" placeholder="Select city">
    3838        <mat-option [value]="city.id" *ngFor="let city of cities" [value]="city.id"> {{city.name}}</mat-option>
    3939      </mat-select>
    4040    </mat-form-field>
    4141  </div>
     42
    4243
    4344  <div *ngIf="regionOption">
     
    6263  <mat-form-field class="example-full-width" appearance="fill">
    6364    <mat-label>Please select a number of days</mat-label>
    64     <input matInput placeholder="No. Days"  type="number" [(ngModel)]="lengthOfStay">
     65    <input matInput placeholder="No. Days"  type="number" min="1" value="0" max="30" [constraintMaxNumberDays()] [(ngModel)]="lengthOfStay">
    6566  </mat-form-field>
    6667
     
    6869  <mat-chip-list  selectable multiple>
    6970    <mat-chip #c="matChip" selected *ngFor="let category of categories"
    70     (click)="toggleSelection(c, category)" >
     71    (click)="toggleSelection(c, category)">
    7172  <mat-icon *ngIf="!c.selected" >check</mat-icon>
    7273  {{category.name}}
    7374  </mat-chip>
    7475  </mat-chip-list>
     76  <br>
    7577  <button mat-raised-button color="primary" (click)="createMyPlanner()">Create my planner</button>
    76 
    7778
    7879</div>
  • trip-planner-front/src/app/locations-form/locations-form.component.ts

    reed0bf8 r188ee53  
    3535  locationId: number;
    3636  regionId: number;
     37  cityId: number;
    3738  companionId: number;
    3839  lengthOfStay: number;
    3940  cityOption: boolean = false;
    4041  regionOption: boolean = false;
     42  value:number;
     43  max: number;
    4144
    4245  constructor(private cityService : CityService, private regionService: RegionService,
     
    5457    this.categoryIds = '';
    5558    this.regionId = 0;
     59    this.cityId = 0;
     60    this.value = 0;
     61    this.max = 30;
    5662  }
    5763 
     
    119125 createMyPlanner(){
    120126   this.categoryIds = this.chipsSeletion.join(',');
    121    console.log(this.companionId);
    122    this.locationService.getAllPlaces(this.locationId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe(
    123      result => {
    124        console.log(result);
    125      }
    126    );
     127   console.log(this.categoryIds);
     128   
     129   if(this.cityOption){
     130    this.locationService.getLocationsFromCity(this.cityId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe(
     131      result => {
     132        console.log(result);
     133      }
     134    );
     135   }else if(this.regionOption){
     136 
     137    this.locationService.getLocationsFromRegion(this.regionId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe(
     138      result => {
     139        console.log(result);
     140      }
     141    );
     142   }
     143   
     144 
    127145 }
    128146 chooseCityOption(){
     
    134152    this.cityOption = false;
    135153  }
     154
     155  constraintMaxNumberDays(){
     156     if(this.value > this.max){
     157       this.value = this.max;
     158     }
     159  }
    136160}
Note: See TracChangeset for help on using the changeset viewer.