Skip to content

Commit

Permalink
moved min and max date range vaues into configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
VoldemLive committed Jan 9, 2025
1 parent 38d5494 commit f37c33e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/views/lab_tests/_date_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<div class="inline-flex items-center">
<span class="mr-3 text-sm font-medium"><%= t('.from') %></span>
<%= f.date_field :start_date,
value: params[:start_date] || Date.today.beginning_of_year,
min: "1900-01-01",
max: "2100-01-01",
value: params[:start_date] || Rails.application.config.x.dates[:default_start_date].call,
min: Rails.application.config.x.dates[:min_date],
max: Rails.application.config.x.dates[:max_date],
onchange: "this.nextElementSibling.nextElementSibling.min=this.value",
class: "rounded-md border border-gray-300 py-2 px-3 mr-6",
placeholder: "mm/dd/yyyy" %>

<span class="mr-3 text-sm font-medium"><%= t('.to') %></span>
<%= f.date_field :end_date,
value: params[:end_date] || Date.today,
min: params[:start_date] || "1900-01-01",
max: "2100-01-01",
value: params[:end_date] || Rails.application.config.x.dates[:default_end_date].call,
min: params[:start_date] || Rails.application.config.x.dates[:min_date],
max: Rails.application.config.x.dates[:max_date],
class: "rounded-md border border-gray-300 py-2 px-3 mr-6",
placeholder: "mm/dd/yyyy" %>

Expand Down
8 changes: 8 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,13 @@ class Application < Rails::Application
# Fixes broken tailwind.css build for CI
# @see https://github.com/rails/tailwindcss-rails/issues/153#issuecomment-1225895063
config.assets.css_compressor = nil

# Date range settings for lab tests
config.x.dates = {
min_date: '1900-01-01',
max_date: '2100-01-01',
default_start_date: -> { Date.today.beginning_of_year },
default_end_date: -> { Date.today }
}
end
end

0 comments on commit f37c33e

Please sign in to comment.