datetime type de champ: changed the years range from [1950;2100] to [to current year - 1;
current year + 50] (or [entered_date; current_year + 50] if old date already entered) because: The type_de_champ Datetime is used for close future dates and very close past dates (for accident declaration for ex.) The select currently has a range from 1950 to 2100, so 70+ years not supposed to be used, leading to: - many bad data entered (0000 or 1950 to not scroll) - making it difficult for users to give the proper date (current date is lost in the middle of 149 others) so risk to be lazy and select a random one or genuinely make a mistake
This commit is contained in:
parent
fb28bdaa15
commit
c27b2da90b
2 changed files with 9 additions and 1 deletions
|
@ -56,4 +56,12 @@ module ChampHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def datetime_start_year(date)
|
||||
if date == nil || date.year == 0 || date.year >= Date.today.year - 1
|
||||
Date.today.year - 1
|
||||
else
|
||||
date.year
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : nil
|
||||
|
||||
.datetime
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5, include_blank: true)
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: datetime_start_year(parsed_value), end_year: Date.today.year + 50, minute_step: 5, include_blank: true)
|
||||
|
|
Loading…
Reference in a new issue