[develop | DONE | CHANGED] add min/max year variables with default values max: current and min: current -20

This commit is contained in:
argirok 2024-02-23 10:12:32 +02:00
parent f5ca757771
commit 7c3c082fc0
1 changed files with 6 additions and 5 deletions

View File

@ -50,7 +50,8 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
selectedFromAndToValues: ""
};
rangeFilter: RangeFilterComponent;
minYear = Dates.currentYear - 20
maxYear = Dates.currentYear
public numberResults: Map<string, number> = new Map<string, number>();
public chartsActiveType: Map<string, IndicatorPath> = new Map<string, IndicatorPath>();
public currentYear = new Date().getFullYear();
@ -179,12 +180,12 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
protected validateYearRange(navigateTo: boolean = false) {
let validYears = true;
if (this.periodFilter.selectedToValue && (this.periodFilter.selectedToValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedToValue, Dates.currentYear - 20, Dates.currentYear))) {
this.periodFilter.selectedToValue = Dates.currentYear + "";
if (this.periodFilter.selectedToValue && (this.periodFilter.selectedToValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedToValue, this.minYear, this.maxYear))) {
this.periodFilter.selectedToValue = this.maxYear + "";
validYears = false;
}
if (this.periodFilter.selectedFromValue && (this.periodFilter.selectedFromValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedFromValue, Dates.currentYear - 20, Dates.currentYear))) {
this.periodFilter.selectedFromValue = Dates.currentYear - 20 + "";
if (this.periodFilter.selectedFromValue && (this.periodFilter.selectedFromValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedFromValue, this.minYear, this.maxYear))) {
this.periodFilter.selectedFromValue = this.minYear + "";
validYears = false;
}
if (this.periodFilter.selectedFromValue && this.periodFilter.selectedFromValue.length && this.periodFilter.selectedToValue && this.periodFilter.selectedToValue.length > 0 && parseInt(this.periodFilter.selectedFromValue, 10) > parseInt(this.periodFilter.selectedToValue, 10)) {