فهرست منبع

🐛 prevent get_zones request with incorrect date

jmacura 3 سال پیش
والد
کامیت
1d2238d6e1

+ 1 - 1
src/app/calculator/calculator.component.html

@@ -41,7 +41,7 @@
       </div>
       <div>
         {{ 'CALCULATOR.selectIndex' | translate}}:&emsp;
-        <select class="form-select" [(ngModel)]="data.selectedProduct">
+        <select class="form-select" [(ngModel)]="data.selectedProduct" (ngModelChange)="resetDate()">
           <option *ngFor="let product of calcService.AVAILABLE_PRODUCTS" [ngValue]="product">{{product}}</option>
         </select>
       </div>

+ 8 - 0
src/app/calculator/calculator.component.ts

@@ -67,6 +67,14 @@ export class CalculatorComponent implements HsPanelComponent {
     });
   }
 
+  /**
+   * Used when product is changed, so the selected date can be reset
+   */
+  resetDate() {
+    this.calcService.selectedDate = undefined;
+    this.calcService.availableDates = undefined;
+  }
+
   updateRangeSlider(value: string) {
     this.calcService.dateCalendarSelects.next({date: value});
   }

+ 1 - 1
src/app/calculator/calculator.service.ts

@@ -23,7 +23,7 @@ export class CalculatorService {
   dateCalendarSelects: Subject<{date: string}> = new Subject();
   lpisLoading = false;
   quantileCount = 4;
-  selectedDate;
+  selectedDate: string;
   //selectedProduct;
   private _datesLoading: boolean;
   private _zonesLoading: boolean;