From bd0b2dc23085d361dd1d74a2125cc43a1d6f8c79 Mon Sep 17 00:00:00 2001 From: Julian Tomczyk Date: Tue, 1 Mar 2022 13:48:52 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20valeurs=20par=20d=C3=A9faut=20de?= =?UTF-8?q?=20la=20fourchette=20de=20prix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter-side-bar.component.html | 4 +-- .../filter-side-bar.component.ts | 32 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/app/components/filter-side-bar/filter-side-bar.component.html b/src/app/components/filter-side-bar/filter-side-bar.component.html index cc3e407..a8be548 100644 --- a/src/app/components/filter-side-bar/filter-side-bar.component.html +++ b/src/app/components/filter-side-bar/filter-side-bar.component.html @@ -23,8 +23,8 @@

Prix

- - + +
diff --git a/src/app/components/filter-side-bar/filter-side-bar.component.ts b/src/app/components/filter-side-bar/filter-side-bar.component.ts index 850a1fc..368067c 100644 --- a/src/app/components/filter-side-bar/filter-side-bar.component.ts +++ b/src/app/components/filter-side-bar/filter-side-bar.component.ts @@ -13,10 +13,16 @@ export class FilterSideBarComponent implements OnInit { @Output() reset = new EventEmitter(); filterStateNumber: number = 0; public selectedCategory: string[]; + public rangeArray: number[]; + public minPrice : any; + public maxPrice : any; constructor() { this.listCategories = []; this.selectedCategory = []; + this.minPrice = 0; + this.maxPrice = 1000; + this.rangeArray = []; } ngOnInit(): void { @@ -45,23 +51,31 @@ export class FilterSideBarComponent implements OnInit { this.filterStateNumber = stateNumber; } - onSendRating(): void { + onSendRating():void { this.stateNumber.emit(this.filterStateNumber); } onSendValues(minNum: any, maxNum: any): void { - if (minNum.value == '') { - minNum.value = 0; + if (minNum.value == "") { + if (maxNum.value == "") { + this.rangeArray = [parseFloat(this.minPrice), parseFloat(this.maxPrice)]; + this.rangeNumber.emit(this.rangeArray); + } else { + this.rangeArray = [parseFloat(this.minPrice), parseFloat(maxNum.value)]; + this.rangeNumber.emit(this.rangeArray) + } + } else { + if (maxNum.value == "") { + this.rangeArray = [parseFloat(minNum.value), parseFloat(this.maxPrice)]; + this.rangeNumber.emit(this.rangeArray); + } else { + this.rangeArray = [parseFloat(minNum.value), parseFloat(maxNum.value)]; + this.rangeNumber.emit(this.rangeArray); + } } - if (maxNum.value == '') { - maxNum.value = 1000; - } - let rangeArray: number[] = [parseFloat(minNum.value), parseFloat(maxNum.value)]; - this.rangeNumber.emit(rangeArray); } onReset(): void { this.reset.emit(); - } }