résolution erreur merge
This commit is contained in:
parent
52cf48a5dd
commit
f6601fcd9c
1 changed files with 109 additions and 113 deletions
|
@ -27,8 +27,6 @@ export class PageAccueilComponent implements OnInit {
|
|||
public isPricingFilterActive: boolean;
|
||||
public isRatingFilterActive: boolean;
|
||||
|
||||
public clickCounter : any;
|
||||
|
||||
constructor(private plantouneService: PlantouneService) {
|
||||
this.listData = [];
|
||||
this.listCategoriesFilter = [];
|
||||
|
@ -118,117 +116,115 @@ console.log(this.clickCounter)
|
|||
if (this.listData.length >= 9) {this.listData.length=9}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onListCategory(categoryArray: string[]) {
|
||||
// this.listData=listData;
|
||||
//console.log(typeof(valueText));
|
||||
|
||||
if(categoryArray.length == 0) {
|
||||
this.listData = [...this.listDataGlobal];
|
||||
|
||||
} else if(categoryArray.length > 0) {
|
||||
let listProductsByCategory:string[] = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
|
||||
categoryArray.forEach(categorySelected => {
|
||||
if (product.product_breadcrumb_label == categorySelected){
|
||||
listProductsByCategory.push(product);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.listData= [...listProductsByCategory];
|
||||
}
|
||||
|
||||
if(this.listData.length>=9){
|
||||
this.listData.length=9;
|
||||
}
|
||||
}
|
||||
|
||||
onRatingFilter(stateNumber: number): void {
|
||||
this.stateNumber = stateNumber;
|
||||
this.isRatingFilterActive = true;
|
||||
|
||||
this.onApplyFilters();
|
||||
}
|
||||
|
||||
onPriceFilter(rangeNumber: number[]) {
|
||||
this.rangeNumber = [...rangeNumber];
|
||||
this.isPricingFilterActive = true;
|
||||
|
||||
this.onApplyFilters();
|
||||
}
|
||||
|
||||
onApplyFilters(): void {
|
||||
this.clickCounter = 0;
|
||||
|
||||
if(this.isPricingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0] && parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
}
|
||||
|
||||
if(this.isRatingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(product.product_rating >= this.stateNumber) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
}
|
||||
|
||||
if(this.isPricingFilterActive && this.isRatingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0]
|
||||
&& parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]
|
||||
&& product.product_rating >= this.stateNumber) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
console.log(this.listData);
|
||||
}
|
||||
|
||||
if(this.listData.length >= 9) this.listData.length = 9;
|
||||
}
|
||||
|
||||
//Tri des prix des plantes par ordre croissant ou décroissant
|
||||
onPriceTri() : void {
|
||||
|
||||
this.clickCounter ++
|
||||
console.log(this.clickCounter)
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => parseFloat(a.product_price) - parseFloat(b.product_price));
|
||||
}else{
|
||||
this.listData.sort((a, b) => parseFloat(b.product_price) - parseFloat(a.product_price));
|
||||
}
|
||||
}
|
||||
|
||||
//Tri des noms des plantes par ordre alphanumérique
|
||||
onAlphaTri() : void {
|
||||
|
||||
this.clickCounter ++
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => (a.product_name > b.product_name) ? 1 : -1)
|
||||
}else{
|
||||
this.listData.sort((a, b) => (b.product_name > a.product_name) ? 1 : -1)
|
||||
}
|
||||
}
|
||||
|
||||
//Tri des avis des plantes par ordre croissant ou décroissant
|
||||
onRatingTri() : void{
|
||||
this.clickCounter ++
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => (a.product_rating > b.product_rating) ? 1 : -1)
|
||||
}else{
|
||||
this.listData.sort((a, b) => (b.product_rating > a.product_rating) ? 1 : -1)
|
||||
}
|
||||
}
|
||||
// this.listData=listData;
|
||||
//console.log(typeof(valueText));
|
||||
|
||||
if(categoryArray.length == 0) {
|
||||
this.listData = [...this.listDataGlobal];
|
||||
|
||||
} else if(categoryArray.length > 0) {
|
||||
let listProductsByCategory:string[] = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
|
||||
categoryArray.forEach(categorySelected => {
|
||||
if (product.product_breadcrumb_label == categorySelected){
|
||||
listProductsByCategory.push(product);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.listData= [...listProductsByCategory];
|
||||
}
|
||||
|
||||
if(this.listData.length>=9){
|
||||
this.listData.length=9;
|
||||
}
|
||||
}
|
||||
|
||||
onRatingFilter(stateNumber: number): void {
|
||||
this.stateNumber = stateNumber;
|
||||
this.isRatingFilterActive = true;
|
||||
|
||||
this.onApplyFilters();
|
||||
}
|
||||
|
||||
onPriceFilter(rangeNumber: number[]) {
|
||||
this.rangeNumber = [...rangeNumber];
|
||||
this.isPricingFilterActive = true;
|
||||
|
||||
this.onApplyFilters();
|
||||
}
|
||||
|
||||
onApplyFilters(): void {
|
||||
this.clickCounter = 0;
|
||||
|
||||
if(this.isPricingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0] && parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
}
|
||||
|
||||
if(this.isRatingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(product.product_rating >= this.stateNumber) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
}
|
||||
|
||||
if(this.isPricingFilterActive && this.isRatingFilterActive) {
|
||||
let listDataFinal: any = [];
|
||||
this.listDataGlobal.forEach(product => {
|
||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0]
|
||||
&& parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]
|
||||
&& product.product_rating >= this.stateNumber) {
|
||||
listDataFinal.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = [...listDataFinal];
|
||||
console.log(this.listData);
|
||||
}
|
||||
|
||||
if(this.listData.length >= 9) this.listData.length = 9;
|
||||
}
|
||||
|
||||
//Tri des prix des plantes par ordre croissant ou décroissant
|
||||
onPriceTri() : void {
|
||||
|
||||
this.clickCounter ++
|
||||
console.log(this.clickCounter)
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => parseFloat(a.product_price) - parseFloat(b.product_price));
|
||||
}else{
|
||||
this.listData.sort((a, b) => parseFloat(b.product_price) - parseFloat(a.product_price));
|
||||
}
|
||||
}
|
||||
|
||||
//Tri des noms des plantes par ordre alphanumérique
|
||||
onAlphaTri() : void {
|
||||
|
||||
this.clickCounter ++
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => (a.product_name > b.product_name) ? 1 : -1)
|
||||
}else{
|
||||
this.listData.sort((a, b) => (b.product_name > a.product_name) ? 1 : -1)
|
||||
}
|
||||
}
|
||||
|
||||
//Tri des avis des plantes par ordre croissant ou décroissant
|
||||
onRatingTri() : void{
|
||||
this.clickCounter ++
|
||||
if (this.clickCounter %2) {
|
||||
this.listData.sort((a, b) => (a.product_rating > b.product_rating) ? 1 : -1)
|
||||
}else{
|
||||
this.listData.sort((a, b) => (b.product_rating > a.product_rating) ? 1 : -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue