From 1737b2a9872c76988959531d8bd3174b16f01eac Mon Sep 17 00:00:00 2001 From: Robin Steiner Date: Mon, 18 Nov 2024 10:22:34 +0100 Subject: [PATCH] Allow future years to be selected in from-to year dropdown --- app/helpers/date_helper.rb | 5 ++--- app/views/application/_daterange_picker.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/helpers/date_helper.rb b/app/helpers/date_helper.rb index 4f9bf098b..4015e0755 100644 --- a/app/helpers/date_helper.rb +++ b/app/helpers/date_helper.rb @@ -24,8 +24,7 @@ def months_with_nil months.compact.each_with_index.map { |month, index| [month, index + 1] } end - def last_100_years - (100.years.ago.year..Time.zone.today.year).to_a.reverse + def year_range + (100.years.ago.year..5.years.from_now.year).to_a.reverse end - end diff --git a/app/views/application/_daterange_picker.html.haml b/app/views/application/_daterange_picker.html.haml index 479351d8f..511ca4df5 100644 --- a/app/views/application/_daterange_picker.html.haml +++ b/app/views/application/_daterange_picker.html.haml @@ -14,7 +14,7 @@ %span.col-5 = form.select :month_from, add_default_option(months_with_nil, { text: '-' }), {}, class: "form-select" %span.col-5 - = form.select :year_from, add_default_option(last_100_years, { hidden: true }),{}, class: "form-select" + = form.select :year_from, add_default_option(year_range, { hidden: true }),{}, class: "form-select" %div{"data-date-picker-target": "hideable", hidden: end_date, id: "end_date_picker"} %div.d-flex.row.align-items-center %span.fw-bold.col-2 @@ -22,7 +22,7 @@ %span.col-5 = form.select :month_to, add_default_option(months_with_nil, { text: '-' }), {}, class: "form-select" %span.col-5 - = form.select :year_to, add_default_option(last_100_years, { hidden: true }), {}, class: "form-select" + = form.select :year_to, add_default_option(year_range, { hidden: true }), {}, class: "form-select" %div{"data-date-picker-target": "hideable", hidden: !end_date} %div.d-flex.justify-content-end %span.d-flex.justify-content-center.fw-bold.py-2.col-10