Skip to content

Commit

Permalink
Allow future years to be selected in from-to year dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin481 committed Nov 18, 2024
1 parent bdffe0d commit 1737b2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/helpers/date_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/views/application/_daterange_picker.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
%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
= "#{ti('date.to')}:"
%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
Expand Down

0 comments on commit 1737b2a

Please sign in to comment.