Correction valeurs par défaut de la fourchette de prix
This commit is contained in:
		
							parent
							
								
									1f1c069bdd
								
							
						
					
					
						commit
						bd0b2dc230
					
				
					 2 changed files with 25 additions and 11 deletions
				
			
		| 
						 | 
					@ -23,8 +23,8 @@
 | 
				
			||||||
    <div class="p-3">
 | 
					    <div class="p-3">
 | 
				
			||||||
      <p class="mb-1 fs-5 fw-semibold">Prix</p>
 | 
					      <p class="mb-1 fs-5 fw-semibold">Prix</p>
 | 
				
			||||||
      <div class="d-flex justify-content-center">
 | 
					      <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 #minNum id="numberMin" type="number" placeholder="min" class="me-2" style="width: 45%;">
 | 
				
			||||||
        <input #maxNum id="numberMax" type="number" placeholder="max" value="" class="me-2" style="width: 45%;">
 | 
					        <input #maxNum id="numberMax" type="number" placeholder="max" class="me-2" style="width: 45%;">
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="d-flex justify-content-center">
 | 
					      <div class="d-flex justify-content-center">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,10 +13,16 @@ export class FilterSideBarComponent implements OnInit {
 | 
				
			||||||
  @Output() reset = new EventEmitter();
 | 
					  @Output() reset = new EventEmitter();
 | 
				
			||||||
  filterStateNumber: number = 0;
 | 
					  filterStateNumber: number = 0;
 | 
				
			||||||
  public selectedCategory: string[];
 | 
					  public selectedCategory: string[];
 | 
				
			||||||
 | 
					  public rangeArray: number[];
 | 
				
			||||||
 | 
					  public minPrice : any;
 | 
				
			||||||
 | 
					  public maxPrice : any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor() {
 | 
					  constructor() {
 | 
				
			||||||
    this.listCategories = [];
 | 
					    this.listCategories = [];
 | 
				
			||||||
    this.selectedCategory = [];
 | 
					    this.selectedCategory = [];
 | 
				
			||||||
 | 
					    this.minPrice = 0;
 | 
				
			||||||
 | 
					    this.maxPrice = 1000;
 | 
				
			||||||
 | 
					    this.rangeArray = [];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnInit(): void {
 | 
					  ngOnInit(): void {
 | 
				
			||||||
| 
						 | 
					@ -50,18 +56,26 @@ export class FilterSideBarComponent implements OnInit {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onSendValues(minNum: any, maxNum: any): void {
 | 
					  onSendValues(minNum: any, maxNum: any): void {
 | 
				
			||||||
    if (minNum.value == '') {
 | 
					    if (minNum.value == "") {
 | 
				
			||||||
      minNum.value = 0;
 | 
					      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 {
 | 
					  onReset(): void {
 | 
				
			||||||
    this.reset.emit();
 | 
					    this.reset.emit();
 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue