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 isPricingFilterActive: boolean;
|
||||||
public isRatingFilterActive: boolean;
|
public isRatingFilterActive: boolean;
|
||||||
|
|
||||||
public clickCounter : any;
|
|
||||||
|
|
||||||
constructor(private plantouneService: PlantouneService) {
|
constructor(private plantouneService: PlantouneService) {
|
||||||
this.listData = [];
|
this.listData = [];
|
||||||
this.listCategoriesFilter = [];
|
this.listCategoriesFilter = [];
|
||||||
|
@ -118,117 +116,115 @@ console.log(this.clickCounter)
|
||||||
if (this.listData.length >= 9) {this.listData.length=9}
|
if (this.listData.length >= 9) {this.listData.length=9}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
onListCategory(categoryArray: string[]) {
|
onListCategory(categoryArray: string[]) {
|
||||||
// this.listData=listData;
|
// this.listData=listData;
|
||||||
//console.log(typeof(valueText));
|
//console.log(typeof(valueText));
|
||||||
|
|
||||||
if(categoryArray.length == 0) {
|
if(categoryArray.length == 0) {
|
||||||
this.listData = [...this.listDataGlobal];
|
this.listData = [...this.listDataGlobal];
|
||||||
|
|
||||||
} else if(categoryArray.length > 0) {
|
} else if(categoryArray.length > 0) {
|
||||||
let listProductsByCategory:string[] = [];
|
let listProductsByCategory:string[] = [];
|
||||||
this.listDataGlobal.forEach(product => {
|
this.listDataGlobal.forEach(product => {
|
||||||
|
|
||||||
categoryArray.forEach(categorySelected => {
|
categoryArray.forEach(categorySelected => {
|
||||||
if (product.product_breadcrumb_label == categorySelected){
|
if (product.product_breadcrumb_label == categorySelected){
|
||||||
listProductsByCategory.push(product);
|
listProductsByCategory.push(product);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.listData= [...listProductsByCategory];
|
this.listData= [...listProductsByCategory];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.listData.length>=9){
|
if(this.listData.length>=9){
|
||||||
this.listData.length=9;
|
this.listData.length=9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRatingFilter(stateNumber: number): void {
|
onRatingFilter(stateNumber: number): void {
|
||||||
this.stateNumber = stateNumber;
|
this.stateNumber = stateNumber;
|
||||||
this.isRatingFilterActive = true;
|
this.isRatingFilterActive = true;
|
||||||
|
|
||||||
this.onApplyFilters();
|
this.onApplyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
onPriceFilter(rangeNumber: number[]) {
|
onPriceFilter(rangeNumber: number[]) {
|
||||||
this.rangeNumber = [...rangeNumber];
|
this.rangeNumber = [...rangeNumber];
|
||||||
this.isPricingFilterActive = true;
|
this.isPricingFilterActive = true;
|
||||||
|
|
||||||
this.onApplyFilters();
|
this.onApplyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
onApplyFilters(): void {
|
onApplyFilters(): void {
|
||||||
this.clickCounter = 0;
|
this.clickCounter = 0;
|
||||||
|
|
||||||
if(this.isPricingFilterActive) {
|
if(this.isPricingFilterActive) {
|
||||||
let listDataFinal: any = [];
|
let listDataFinal: any = [];
|
||||||
this.listDataGlobal.forEach(product => {
|
this.listDataGlobal.forEach(product => {
|
||||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0] && parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]) {
|
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0] && parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]) {
|
||||||
listDataFinal.push(product);
|
listDataFinal.push(product);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.listData = [...listDataFinal];
|
this.listData = [...listDataFinal];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isRatingFilterActive) {
|
if(this.isRatingFilterActive) {
|
||||||
let listDataFinal: any = [];
|
let listDataFinal: any = [];
|
||||||
this.listDataGlobal.forEach(product => {
|
this.listDataGlobal.forEach(product => {
|
||||||
if(product.product_rating >= this.stateNumber) {
|
if(product.product_rating >= this.stateNumber) {
|
||||||
listDataFinal.push(product);
|
listDataFinal.push(product);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.listData = [...listDataFinal];
|
this.listData = [...listDataFinal];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isPricingFilterActive && this.isRatingFilterActive) {
|
if(this.isPricingFilterActive && this.isRatingFilterActive) {
|
||||||
let listDataFinal: any = [];
|
let listDataFinal: any = [];
|
||||||
this.listDataGlobal.forEach(product => {
|
this.listDataGlobal.forEach(product => {
|
||||||
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0]
|
if(parseFloat(product.product_unitprice_ati) >= this.rangeNumber[0]
|
||||||
&& parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]
|
&& parseFloat(product.product_unitprice_ati) <= this.rangeNumber[1]
|
||||||
&& product.product_rating >= this.stateNumber) {
|
&& product.product_rating >= this.stateNumber) {
|
||||||
listDataFinal.push(product);
|
listDataFinal.push(product);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.listData = [...listDataFinal];
|
this.listData = [...listDataFinal];
|
||||||
console.log(this.listData);
|
console.log(this.listData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.listData.length >= 9) this.listData.length = 9;
|
if(this.listData.length >= 9) this.listData.length = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tri des prix des plantes par ordre croissant ou décroissant
|
//Tri des prix des plantes par ordre croissant ou décroissant
|
||||||
onPriceTri() : void {
|
onPriceTri() : void {
|
||||||
|
|
||||||
this.clickCounter ++
|
this.clickCounter ++
|
||||||
console.log(this.clickCounter)
|
console.log(this.clickCounter)
|
||||||
if (this.clickCounter %2) {
|
if (this.clickCounter %2) {
|
||||||
this.listData.sort((a, b) => parseFloat(a.product_price) - parseFloat(b.product_price));
|
this.listData.sort((a, b) => parseFloat(a.product_price) - parseFloat(b.product_price));
|
||||||
}else{
|
}else{
|
||||||
this.listData.sort((a, b) => parseFloat(b.product_price) - parseFloat(a.product_price));
|
this.listData.sort((a, b) => parseFloat(b.product_price) - parseFloat(a.product_price));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tri des noms des plantes par ordre alphanumérique
|
//Tri des noms des plantes par ordre alphanumérique
|
||||||
onAlphaTri() : void {
|
onAlphaTri() : void {
|
||||||
|
|
||||||
this.clickCounter ++
|
this.clickCounter ++
|
||||||
if (this.clickCounter %2) {
|
if (this.clickCounter %2) {
|
||||||
this.listData.sort((a, b) => (a.product_name > b.product_name) ? 1 : -1)
|
this.listData.sort((a, b) => (a.product_name > b.product_name) ? 1 : -1)
|
||||||
}else{
|
}else{
|
||||||
this.listData.sort((a, b) => (b.product_name > a.product_name) ? 1 : -1)
|
this.listData.sort((a, b) => (b.product_name > a.product_name) ? 1 : -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tri des avis des plantes par ordre croissant ou décroissant
|
//Tri des avis des plantes par ordre croissant ou décroissant
|
||||||
onRatingTri() : void{
|
onRatingTri() : void{
|
||||||
this.clickCounter ++
|
this.clickCounter ++
|
||||||
if (this.clickCounter %2) {
|
if (this.clickCounter %2) {
|
||||||
this.listData.sort((a, b) => (a.product_rating > b.product_rating) ? 1 : -1)
|
this.listData.sort((a, b) => (a.product_rating > b.product_rating) ? 1 : -1)
|
||||||
}else{
|
}else{
|
||||||
this.listData.sort((a, b) => (b.product_rating > a.product_rating) ? 1 : -1)
|
this.listData.sort((a, b) => (b.product_rating > a.product_rating) ? 1 : -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue