From f6601fcd9c77adba77e560a23e01299549ff61d6 Mon Sep 17 00:00:00 2001 From: Julian Tomczyk Date: Wed, 19 Jan 2022 13:38:48 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9solution=20erreur=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page-accueil/page-accueil.component.ts | 222 +++++++++--------- 1 file changed, 109 insertions(+), 113 deletions(-) diff --git a/src/app/pages/page-accueil/page-accueil.component.ts b/src/app/pages/page-accueil/page-accueil.component.ts index df31350..2ee718c 100644 --- a/src/app/pages/page-accueil/page-accueil.component.ts +++ b/src/app/pages/page-accueil/page-accueil.component.ts @@ -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) + } + } }