Commit Rating (Julian)
This commit is contained in:
parent
2225415f75
commit
cf65a3a258
2 changed files with 24 additions and 10 deletions
|
@ -1,14 +1,14 @@
|
||||||
<div class="d-flex align-items-stretch">
|
<div class="d-flex align-items-stretch">
|
||||||
<app-filter-side-bar [listCategories]="listCategoriesFilter"></app-filter-side-bar>
|
<app-filter-side-bar [listCategories]="listCategoriesFilter" (stateNumber)=onRatingFilter($event)></app-filter-side-bar>
|
||||||
|
|
||||||
<div class="custom-main container p-3">
|
<div class="custom-main container p-3">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Recherche ta belle plante"
|
placeholder="Recherche ta belle plante"
|
||||||
aria-label="Input Recherche ta belle plante">
|
aria-label="Input Recherche ta belle plante">
|
||||||
|
|
||||||
<div class="py-3">
|
<div class="py-3">
|
||||||
Trier par :
|
Trier par :
|
||||||
<button class="btn btn-outline-success btn-sm me-2">Prix</button>
|
<button class="btn btn-outline-success btn-sm me-2">Prix</button>
|
||||||
<button class="btn btn-outline-success btn-sm me-2">Ordre Alpha</button>
|
<button class="btn btn-outline-success btn-sm me-2">Ordre Alpha</button>
|
||||||
<button class="btn btn-outline-success btn-sm me-2">Avis</button>
|
<button class="btn btn-outline-success btn-sm me-2">Avis</button>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col" *ngFor="let product of listData">
|
<div class="col" *ngFor="let product of listData">
|
||||||
<app-card-plante [plant]="product"
|
<app-card-plante [plant]="product"
|
||||||
(clickLike)="onEventLike()">
|
(clickLike)="onEventLike()">
|
||||||
</app-card-plante>
|
</app-card-plante>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,18 +9,20 @@ import * as _ from 'underscore';
|
||||||
})
|
})
|
||||||
export class PageAccueilComponent implements OnInit {
|
export class PageAccueilComponent implements OnInit {
|
||||||
public listData: any[];
|
public listData: any[];
|
||||||
|
public listRate: any[];
|
||||||
public listCategoriesFilter: string[];
|
public listCategoriesFilter: string[];
|
||||||
|
|
||||||
constructor(private plantouneService: PlantouneService) {
|
constructor(private plantouneService: PlantouneService) {
|
||||||
this.listData = [];
|
this.listData = [];
|
||||||
|
this.listRate = [];
|
||||||
this.listCategoriesFilter = [];
|
this.listCategoriesFilter = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* equivalent de la ligne du dessus
|
* equivalent de la ligne du dessus
|
||||||
*
|
*
|
||||||
* plantouneService;
|
* plantouneService;
|
||||||
*
|
*
|
||||||
* constructor(plantouneService: PlantouneService) {
|
* constructor(plantouneService: PlantouneService) {
|
||||||
* this.plantouneService = plantouneService;
|
* this.plantouneService = plantouneService;
|
||||||
* }
|
* }
|
||||||
|
@ -39,10 +41,10 @@ export class PageAccueilComponent implements OnInit {
|
||||||
*/
|
*/
|
||||||
const listAllCategories = listPlant.map(product => product.product_breadcrumb_label);
|
const listAllCategories = listPlant.map(product => product.product_breadcrumb_label);
|
||||||
console.log(listAllCategories);
|
console.log(listAllCategories);
|
||||||
|
|
||||||
const listUniqCategories = _.uniq(listAllCategories)
|
const listUniqCategories = _.uniq(listAllCategories)
|
||||||
console.log(listUniqCategories);
|
console.log(listUniqCategories);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Technique native JS pour recupérer les catégories uniques de nos plantes
|
* Technique native JS pour recupérer les catégories uniques de nos plantes
|
||||||
|
@ -54,6 +56,7 @@ export class PageAccueilComponent implements OnInit {
|
||||||
this.listCategoriesFilter = listUniqJsCategories;
|
this.listCategoriesFilter = listUniqJsCategories;
|
||||||
this.listData = listPlant;
|
this.listData = listPlant;
|
||||||
this.listData.length = 9;
|
this.listData.length = 9;
|
||||||
|
console.log(this.listData);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -62,4 +65,15 @@ export class PageAccueilComponent implements OnInit {
|
||||||
this.plantouneService.plantLiked$.next('')
|
this.plantouneService.plantLiked$.next('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRatingFilter(stateNumber: number): void {
|
||||||
|
console.log(stateNumber);
|
||||||
|
this.listData.forEach(product => {
|
||||||
|
if(product.product_rating >= stateNumber) {
|
||||||
|
this.listRate.push(product);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.listData = this.listRate;
|
||||||
|
console.log(this.listData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue