From c254e4e7b71dd0f859cc27a93f424e98139d5314 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 1 May 2024 17:44:54 +0200 Subject: [PATCH] Calendar - add option to change step size in yearpicker --- src/app/components/calendar/calendar.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index 37fd1cd6592..e5b44344c0b 100644 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -604,6 +604,11 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { * @group Props */ @Input({ transform: booleanAttribute }) timeOnly: boolean | undefined; + /** + * Years to change per step in yearpicker. + * @group Props + */ + @Input({ transform: numberAttribute }) stepYearPicker: number = 20; /** * Hours to change per step. * @group Props @@ -1284,8 +1289,8 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { yearPickerValues() { let yearPickerValues = []; - let base = this.currentYear - (this.currentYear % 10); - for (let i = 0; i < 10; i++) { + let base = this.currentYear - (this.currentYear % this.stepYearPicker); + for (let i = 0; i < this.stepYearPicker; i++) { yearPickerValues.push(base + i); } @@ -1407,7 +1412,7 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { this.updateFocus(); }, 1); } else if (this.currentView === 'year') { - this.decrementDecade(); + this.decrementYearPickerStep(); setTimeout(() => { this.updateFocus(); }, 1); @@ -1438,7 +1443,7 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { this.updateFocus(); }, 1); } else if (this.currentView === 'year') { - this.incrementDecade(); + this.incrementYearPickerStep(); setTimeout(() => { this.updateFocus(); }, 1); @@ -1465,12 +1470,12 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } } - decrementDecade() { - this.currentYear = this.currentYear - 10; + decrementYearPickerStep() { + this.currentYear = this.currentYear - this.stepYearPicker; } - incrementDecade() { - this.currentYear = this.currentYear + 10; + incrementYearPickerStep() { + this.currentYear = this.currentYear + this.stepYearPicker; } incrementYear() {