avancement filtres

This commit is contained in:
Romain Verger 2022-02-14 16:51:32 +01:00
parent 5d3549b0b6
commit 637e8f75cd
4 changed files with 85 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
@Component({ @Component({
selector: 'app-avis-bar', selector: 'app-avis-bar',
@ -8,6 +8,8 @@ import { Component, OnInit } from '@angular/core';
export class AvisBarComponent implements OnInit { export class AvisBarComponent implements OnInit {
starStates: {stateSelectedUser : boolean, stateHoverUser : boolean}[]; starStates: {stateSelectedUser : boolean, stateHoverUser : boolean}[];
@Output() stateNumber = new EventEmitter();
starStateNumber: number = 0;
constructor() { constructor() {
@ -29,7 +31,6 @@ export class AvisBarComponent implements OnInit {
} }
onMouseOver(index: number) { onMouseOver(index: number) {
console.log("star over", index);
for (let i = 0; i < this.starStates.length ; i++) { for (let i = 0; i < this.starStates.length ; i++) {
if(i <= index) { if(i <= index) {
this.starStates[i].stateHoverUser = true; this.starStates[i].stateHoverUser = true;
@ -53,13 +54,17 @@ export class AvisBarComponent implements OnInit {
} }
onClickStar(starIndex: number) { onClickStar(starIndex: number) {
this.starStateNumber = 0;
for (let i = 0; i < this.starStates.length ; i++) { for (let i = 0; i < this.starStates.length ; i++) {
if(i <= starIndex) { if(i <= starIndex) {
this.starStates[i].stateSelectedUser = true; this.starStates[i].stateSelectedUser = true;
this.starStateNumber++;
} else { } else {
this.starStates[i].stateSelectedUser = false; this.starStates[i].stateSelectedUser = false;
} }
} }
//console.log(`Rating : ${this.starStateNumber}`);
this.stateNumber.emit(this.starStateNumber);
} }
} }

View File

@ -67,8 +67,8 @@
<span>A Emporter</span> <span>A Emporter</span>
</div> </div>
<div class="PlaceEmporterCheck m-3 d-flex justify-content-around"> <div class="PlaceEmporterCheck m-3 d-flex justify-content-around">
<input class="surPlace-check-input" type="checkbox" value="surPlaceOption" style="width: 25px; height: 25px; border-radius: 300px;"> <input class="surPlace-check-input" type="checkbox" value="surPlaceOption" style="width: 25px; height: 25px; border-radius: 300px;" (change) = "changeValueSurPlace($event)">
<input class="Emporter-check-input" type="checkbox" value="aEmporterOption" style="width: 25px; height: 25px;"> <input class="Emporter-check-input" type="checkbox" value="aEmporterOption" style="width: 25px; height: 25px;" (change) = "changeValueEmporter($event)">
</div> </div>
</div> </div>
</div> </div>
@ -89,7 +89,7 @@
<span>Accès PMR</span> <span>Accès PMR</span>
</div> </div>
<div class="pmr-check d-flex justify-content-center p-2"> <div class="pmr-check d-flex justify-content-center p-2">
<input class="pmr-check-input mx-auto" type="checkbox" value="" style="width: 25px; height: 25px;"> <input class="pmr-check-input mx-auto" type="checkbox" value="AccesPMR" style="width: 25px; height: 25px;" (change) = "changeValuePMR($event)">
</div> </div>
</div> </div>
</div> </div>
@ -108,7 +108,7 @@
<div class="titreAvis m-3 d-flex justify-content-around"> <div class="titreAvis m-3 d-flex justify-content-around">
<span>Choisissez parmi les avis déjà donnés</span> <span>Choisissez parmi les avis déjà donnés</span>
</div> </div>
<app-avis-bar></app-avis-bar> <app-avis-bar (stateNumber)="onStateNumberChange($event)"></app-avis-bar>
</div> </div>
</div> </div>
</div> </div>
@ -116,5 +116,7 @@
</div> </div>
<button class="btn-search btn-primary" type="button">LANCER LA RECHERCHE</button> <button class="btn-search btn-primary" type="button"
(click) = "onSendFilters()"
(click) ="onSendRating()">LANCER LA RECHERCHE</button>

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
import { ApiBackService } from 'src/app/services/api-back.service';
@Component({ @Component({
selector: 'app-filters-page', selector: 'app-filters-page',
@ -9,37 +11,90 @@ export class FiltersPageComponent implements OnInit {
minDistance : any; minDistance : any;
maxDistance : any; maxDistance : any;
selectDistance : any;
minPrice : any; minPrice : any;
maxPrice: any; maxPrice: any;
selectPrice : any; selectPrice : any;
selectDistance : any;
selectPmr :any;
selectSurPlace : any;
selectEmporter : any;
constructor() { @Output() stateNumber = new EventEmitter();
@Output() rangeNumber = new EventEmitter();
selectRating: number;
listRestau: string[];
constructor(private apiBackService : ApiBackService, private route : Router) {
this.minDistance = 0; this.minDistance = 0;
this.maxDistance = 4; this.maxDistance = 4;
this.selectDistance = 0; this.selectDistance = null;
this.minPrice = 0; this.minPrice = 0;
this.maxPrice = 20; this.maxPrice = 20;
this.selectPrice = 0; this.selectPrice = null;
} this.selectPmr = false;
this.selectEmporter = false;
this.selectSurPlace = false;
this.selectRating = 0;
ngOnInit(): void {} this.listRestau = [];
changeValueDistance(valueDistance: any){ }
this.selectDistance = valueDistance.target.value;
console.log(this.selectDistance); ngOnInit(): void {
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
this.listRestau = restaurants;
console.log(this.listRestau);
});
}
changeValueDistance(valueDistance: any){
this.selectDistance = valueDistance.target.value;
} }
changeValuePrice(valuePrice: any){ changeValuePrice(valuePrice: any){
this.selectPrice = valuePrice.target.value; this.selectPrice = valuePrice.target.value;
console.log(this.selectPrice); }
changeValuePMR(valuePmr : any){
this.selectPmr = (valuePmr.target.checked);
}
changeValueSurPlace(valuePlace : any){
this.selectSurPlace = valuePlace.target.checked;
}
changeValueEmporter(valueEmporter : any){
this.selectEmporter = valueEmporter.target.checked;
}
onStateNumberChange(stateNumber: number): void {
this.selectRating = stateNumber;
}
onSendRating():void {
this.stateNumber.emit(this.selectRating);
}
onSendFilters(){
console.log("distance : " + this.selectDistance);
console.log("prix : " +this.selectPrice);
console.log("sur Place : " +this.selectSurPlace);
console.log("A Emporter : " +this.selectEmporter);
console.log("Acces PMR : " +this.selectPmr);
console.log("Avis : " +this.selectRating);
console.log()
} }
} }

View File

@ -22,6 +22,8 @@ export class RestoPageComponent implements OnInit {
}); });
} }
} }