From 7c3c082fc0636faee3d68e11c86051a9089be3fd Mon Sep 17 00:00:00 2001 From: argirok Date: Fri, 23 Feb 2024 10:12:32 +0200 Subject: [PATCH] [develop | DONE | CHANGED] add min/max year variables with default values max: current and min: current -20 --- .../monitor-indicator-stakeholder-base.component.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/monitor/monitor-indicator-stakeholder-base.component.ts b/monitor/monitor-indicator-stakeholder-base.component.ts index ee7bb511..8c95c6d6 100644 --- a/monitor/monitor-indicator-stakeholder-base.component.ts +++ b/monitor/monitor-indicator-stakeholder-base.component.ts @@ -50,7 +50,8 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator selectedFromAndToValues: "" }; rangeFilter: RangeFilterComponent; - + minYear = Dates.currentYear - 20 + maxYear = Dates.currentYear public numberResults: Map = new Map(); public chartsActiveType: Map = new Map(); 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)) {