Correction valeurs par défaut de la fourchette de prix

This commit is contained in:
Julian Tomczyk 2022-03-01 13:48:52 +01:00
parent 1f1c069bdd
commit bd0b2dc230
2 changed files with 25 additions and 11 deletions

View File

@ -23,8 +23,8 @@
<div class="p-3">
<p class="mb-1 fs-5 fw-semibold">Prix</p>
<div class="d-flex justify-content-center">
<input #minNum id="numberMin" type="number" placeholder="min" min=0 value="" class="me-2" style="width: 45%;">
<input #maxNum id="numberMax" type="number" placeholder="max" value="" class="me-2" style="width: 45%;">
<input #minNum id="numberMin" type="number" placeholder="min" class="me-2" style="width: 45%;">
<input #maxNum id="numberMax" type="number" placeholder="max" class="me-2" style="width: 45%;">
</div>
<div class="d-flex justify-content-center">

View File

@ -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();
}
}